several statements in one query

G

Guest

Hi,

I am new to access (obviously) and am wondering how to do the following.

Assume a table containing cd prices, each cd associated with a category (as in rock, pop etc etc). I want to use the sum functions to make a query that will summarize the value of the CDs in the different categories.

Example

Title Category Price
xxx rock 10
yyy pop 12
zzz pop 11
xyz rock 10

should return:
rock 20 pop 23

I know how to make these summaries individually but how do I write the two of them in one statement??

select sum(Price) where Category ="rock"
select sum(Price) where Category ="pop"

How do I combine these statements into just the one query?

Any help appreciated
 
G

Gary Miller

Econ,

Create a new query, pull in your two fields, go up to
View/Totals and now set the Totals line in the grid to be
"GroupBy" for Category and "Sum" for the Price field.

Gary Miller
Sisters, OR

message
Hi,

I am new to access (obviously) and am wondering how to do the following.

Assume a table containing cd prices, each cd associated
with a category (as in rock, pop etc etc). I want to use the
sum functions to make a query that will summarize the value
of the CDs in the different categories.
Example

Title Category Price
xxx rock 10
yyy pop 12
zzz pop 11
xyz rock 10

should return:
rock 20 pop 23

I know how to make these summaries individually but how do
I write the two of them in one statement??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top