|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help with a query
I'm trying to make a query using SQL that specifies the number of test takers in a specific date range, grouped by race, and grouped by age but in groups of 10(ex. age 30-40, 41-50, etc...). It should look something like this...
|30-40|41-50|51-60|61-70|71+| white| | | | | | black| | | | | | asian| | | | | | sorry for the horrible drawing, I don't know how to explain it any better. Please contact me ASAP because I'm running into my deadline!!!! HELP!!!! |
|
#2
|
|||
|
|||
|
RE: Need help with a query
I don't believe with ANSI standard SQL that you are going to be able to achieve output like you are looking for. What DBMS are you using? It is possible that you might be able to use specific features of it (like stored procedures in MSSQL) to obtain that output....
|
|
#3
|
|||
|
|||
|
RE: Need help with a query
I'm using MS Access 2002. do you know if this can be done with this program? If I cant use SQL, is it possible to achieve this with VBA?
|
|
#4
|
|||
|
|||
|
RE: Need help with a query
Well, I can tell you that you can definately create a report in Access that will give you what you want. I haven't messed with Access2002, but I can tell you that it can be done with Access97. Look into the reporting features of the program. You should be able to set labels for your age ranges, and labels for your race. Then do queries such as:
SELECT count(*) FROM table WHERE age <= 40 AND age >=30 AND race='white' to fill in the values.... |
|
#5
|
|||
|
|||
|
RE: Need help with a query
sorry, but for some reason Its returning zero.
|
|
#6
|
|||
|
|||
|
RE: Need help with a query
Well, you will need to fine tune the query for your particular table and such. That was just an example...
|
|
#7
|
|||
|
|||
|
RE: Need help with a query
Ok, I used this code for every field in my table I made in a report so for this example, this field is under Age 30-40, next to Asian.
SELECT Count(survey.[age:]) AS age3040 FROM Survey WHERE Survey.[Age:]>=30 and Survey.[age:]<=40 And (((Survey.[Date:]) Between forms!daterange3!startdate3 And forms!daterange3!enddate3)) and Survey.[Which of these categories describes you?]="Asian"; This works acctually! the only problem is is that it only can handle 6 races (30 fields). When I try to add another race (which is five fields more), and try to point the field to the query it says "query too complex". What I did was take every query for each field and put that into another query and set that as the record source of the report. so when I add another five queries to the query master, it says too complex. I also tryed grouping the queries together by race so the query master would only have 5 queries, but it doesn't work. I hope I'm not confusing you, sorry. based on this code, do you have any ideas that would be able to strip it so it wouldn't be so complex (even though it doesn't look so complex to me). |
|
#8
|
|||
|
|||
|
RE: Need help with a query
I know this question's been sitting here for a while, but I saw the answer in a devshed.com article once.
Check out: http://www.devshed.com/Server_Side/MySQL/MySQLWiz/page1.html |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Need help with a query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|