Español Français Deutsch Italiano Nederlands Svenska Dansk Japanese Chinese (Simplified) Russian
 
AVForums.com twitter AVForums is a member of CEDIA. THX certified reviewer.  Click for more information. AVForums reviewers are ISF Certified.  Click for more information.
 
The UK's biggest and best home entertainment electronics forums  
4 million visitors each month


Forums Register Blogs Information Social Groups Search Today's Posts Mark Forums Read
Go Back   AVForums.com > Lifestyle Topics > General Chat

Latest AVForums Movie Reviews
Galaxy Quest Blu-ray ReviewMy Bloody Valentine - Special Edition Blu-ray ReviewThe Universe: Complete Season One Blu-ray ReviewTerminator Salvation Blu-ray Review20th Century Boys: Chapter 2 - The Last Hope Blu-ray Review
North By Northwest (50th Anniversary Edition Blu-ray Book) Blu-ray ReviewScrooge (A Christmas Carol) Blu-ray ReviewGray Lady Down - Original Motion Picture Soundtrack CD ReviewUp Blu-ray ReviewLéon Blu-ray Review

Similar Threads
thread Thread Starter Forum Replies Last Post
Demon's Souls (US/Asian Import Only) - Preview/Play & Help Thread Widge PS3 Games 636 14-11-2009 10:55 PM
Angels & Demons Richfell Blu-ray Movies and TV Programmes 30 06-10-2009 5:30 PM
MS Windows 7 Pre-order from £49.99 BlkKnight Windows 7 705 12-09-2009 4:21 PM

Reply
 
Thread Tools Display Modes
Old 14-07-2009, 9:41 AM   #1 (permalink)
Prominent Member
 
Shoka's Avatar
 
Join Date: Jan 2002
Location: Surrey
Posts: 3,430
Thanks: Gave 215, Got 135
Is anyone a demon in MS Access?

I'm trying to manipulate some data at work but cannot manage to achieve what I want to do.

I have several records which contain the same(ish) data for example:

ProductQTYPrice
Milk2£0.50
Milk1£0.25
Bread1£0.50
Bread3£1.50

What I want to achieve is a new table with just 1 record per product but with the QTY and Price for the matching records summed.

Is it possible?
Shoka is offline   Reply With Quote
Old 14-07-2009, 9:58 AM   #2 (permalink)
Member
 
Join Date: Sep 2006
Location: Leeds
Posts: 234
Thanks: Gave 31, Got 39
Re: Is anyone a demon in MS Access?

Im guessing you want to group the same product names together and total the quantity and price fields, you can do that in a query like:

SELECT Product, Sum(Qty) AS TotalQty, Sum(Price) AS TotalPrice FROM <TableName> GROUP BY Product;

...or another way of getting the same output would be to...
Go to the query sidetab click New
Add the table to the query
Click "Totals" (on the iconbar, its the Sigma button)
You then get an extra row (called "total") at the bottom
Double-click the Product field, Qty field and Price field so they appear at the bottom
They should all have a "total" calue of "Group By". Leave that for Product (as youre grouping by product code), change "total" for Qty and Price fields to "Sum" (add grouped items together).

You can then click "View" to see the contents of the query, or change it to a Make Table query to make a new table. I recommend saving this as a query as it will change with the products table, it helps you to keep your data in sync and will behave just like a table for most things you want to do with it (except you cant edit it).

Hope this helps,
Jas.
jasonf01 is offline   Reply With Quote
Thanks from:
Shoka (14-07-2009)
Old 14-07-2009, 10:14 AM   #3 (permalink)
Prominent Member
 
Shoka's Avatar
 
Join Date: Jan 2002
Location: Surrey
Posts: 3,430
Thanks: Gave 215, Got 135
Re: Is anyone a demon in MS Access?

Quote:
Originally Posted by jasonf01 View Post
Im guessing you want to group the same product names together and total the quantity and price fields, you can do that in a query like:

SELECT Product, Sum(Qty) AS TotalQty, Sum(Price) AS TotalPrice FROM <TableName> GROUP BY Product;

...or another way of getting the same output would be to...
Go to the query sidetab click New
Add the table to the query
Click "Totals" (on the iconbar, its the Sigma button)
You then get an extra row (called "total") at the bottom
Double-click the Product field, Qty field and Price field so they appear at the bottom
They should all have a "total" calue of "Group By". Leave that for Product (as youre grouping by product code), change "total" for Qty and Price fields to "Sum" (add grouped items together).

You can then click "View" to see the contents of the query, or change it to a Make Table query to make a new table. I recommend saving this as a query as it will change with the products table, it helps you to keep your data in sync and will behave just like a table for most things you want to do with it (except you cant edit it).

Hope this helps,
Jas.
You are a legend - thanks a tonne! works perfectly and achieved exactly what I wanted to do.
Shoka is offline   Reply With Quote
Old 14-07-2009, 11:46 AM   #4 (permalink)
Member
 
Join Date: Sep 2006
Location: Leeds
Posts: 234
Thanks: Gave 31, Got 39
Re: Is anyone a demon in MS Access?

Youre welcome, glad it worked for you.

On a side note, if anyone in Yorkshire is looking for an innovative developer with 18+ years of varied experience in software, hardware and interfaces, feel free to drop me a PM.

(shameless plug!)

Jas.
jasonf01 is offline   Reply With Quote



Bookmarks

Tags
access, demon
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


All times are GMT. The time now is 6:16 PM.

AV Forums
Optimised for Firefox.
RSS Feed
AVForums.com is owned and operated by M2N Limited.
Copyright © 2000-2009 M2N E. & O. E.
Global Gold
Web Hosting