[thelist] Phriday Phreebie
Ben Dyer
ben_dyer at imaginuity.com
Fri May 10 09:58:01 CDT 2002
Because I needed this today, because I've been quiet for a while and
because I probably owe from somewhere...
--Ben
<tip type="SQL" author="Ben Dyer">
Suppose you have a Clients table and a Projects table and you need a query
to find out which clients have the most projects in the database (or
anything else where you need to know how many times records from a field in
Table A appear in its related field in Table B).
SELECT txtCustID
, COUNT(txtCustID) AS tmpCustCount
FROM tblProject
GROUP BY txtCustID
ORDER BY COUNT(txtCustID) DESC
This will return something like:
-------------------------
txtCustID tmpCustCount
-------------------------
CSCO 2637
MSFT 1845
APPL 1325
DELL 978
YHOO 867
</tip>
Ben Dyer, Senior Internet Developer, Imaginuity Interactive
http://www.imaginuity.com/
I'm reading your e-mail right now.
-----------------------------------------------------------------
http://members.evolt.org/OKolzig37/ http://www.evolt.org/
More information about the thelist
mailing list