Stacking Queries

dubs

New Member
Joined
Jul 10, 2003
Messages
45
Hi all,

Im trying to stack some queries which will produce a table of totals...i have around 40 of these so would like these to populate the same table... i could write all 40 out separately and use another query to join them but would much rather stack the queries together so i dont have to create 40 very similar queries, ive tried adding the query to the bottom of the previous one separting by a semi colon but get an error message 'Characters found after sql statement' so have tried to take the semicolon away and try other characters like +, And etc but then i get a syntax error:

SELECT Count(census.Id) AS 1985m
FROM census
WHERE (((census.DOB)>=#09/01/1985# AND(census.dob)<=#8/31/1986#)) and ((Sex)="Male")

WHAT WOULD GO HERE TO TELL ACCESS TO RUN THE NEXT QUERY?

SELECT Count(census.Id) AS 1985f
FROM census
WHERE (((census.DOB)>=#09/01/1985# AND(census.dob)<=#8/31/1986#)) and ((Sex)="Female");

is there a way to stack these queries together or do i have to run 40 separate queries?

greg
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Why do you have to write seperate queries?

Can't you just use a totals query where you group by sex and year?

The SQL would look something like this:

SELECT Year([DOB]) AS Year, census.Sex, Count(census.Sex) AS CountOfSex
FROM census
GROUP BY Year([DOB]), census.Sex;
 
Upvote 0

Forum statistics

Threads
1,221,845
Messages
6,162,350
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top