...

View Full Version : Lopos and querys



dawilis
11-08-2003, 04:47 AM
I need to be able to get a report out of my table, but iM having trouble getting my head around it.
the table gathers info about age
tabel 'Members'
-15
15-24
25-34
35-44
45-64
65+

and policy
Cancer
Mental Health
Cardiovascular Health
Injury Poisoning
Injury Poisoning

I need to sumurise and total all members in each age bracket
against the policy
-15 ---- Cancer ---- '2'
15-24 -- Cancer --- '3'
25-34 -- Cancer --'6'
etc etc
15 --Mental health -- '2'
25-24 Mental Health --'2'

get the idea
so wahts the best way to do this?

A1ien51
11-08-2003, 01:55 PM
SELECT ageColumnName, COUNT(ageColumnName) AS numPeople, policyColumnName FROM MemberTableName GROUP BY ageColumnName, numPeople, policyColumnName


that would get you started....

jeskel
11-08-2003, 08:34 PM
for age use.... wouldn't it be easier for you to create a value for a range of ages when the age is submitted in the first place?

like:



if age<15 then
ageRange=1
end if

if (age<=15) AND (age<=24) then
ageRange=2
end if
............

you can still store the age of the user in a column like "ageExact" and its age range in a column like "ageRange" (which would make it easier for sql use)... I don't know if that post can help actually, maybe that you already do it and that I didn't get it. I guess the sql statement that wrote A1ien51 will maybe be easier for you to make work properly if you do that first since you'll only have to use a single number for your request (for example, 3 would mean people between 25 and 34).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum