[thelist] Better way to do this (SQL)?

david.landy at somerfield.co.uk david.landy at somerfield.co.uk
Thu May 20 05:51:00 CDT 2004


Thanks to John and Sarah for the inspiration:

SELECT Count(*) AS TotalBoth, (SELECT Count(*) FROM test WHERE sex = 'M') AS
TotalMale, (SELECT Count(*) FROM test WHERE sex = 'F') AS TotalFemale,
100*TotalMale/TotalBoth AS PctMale, 100*TotalFemale/TotalBoth AS PctFemale
FROM test

Works like a charm on Access over JDBC/ODBC.

So _this_ is the answer to how to run the queries I was stuck on last week!

Thanks again,

David

-- 
David Landy, IT Consultant, Business Intelligence
Somerfield/KwikSave Support Centre
Whitchurch, Bristol, UK. Tel: 0117 301 8977
david.landy at somerfield.co.uk <mailto:david.landy at somerfield.co.uk>    
 
This is the true joy of life. The being used for a purpose 
Recognized by yourself as a mighty one. 
George Bernard Shaw
 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield.  Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.


More information about the thelist mailing list