Try this:

select  top 1 userID, count(course) from <tablename>
group by userid
order by 2 desc

select top 1 course, count(userid) from <tablename>
group by course
order by 2 desc



-----Original Message-----
From: Chris Lott [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 05, 2000 8:03 PM
To: CF-Talk
Subject: SOT: SQL question


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In a table something like this:

userid, course
john     ethics
john     english
mary     english
mary     math
mary     bio

I need to find 

a) which user has taken the most courses in total
b) which course was taken the most often

Ideas?

c

-----BEGIN PGP SIGNATURE-----
Version: 6.5.8ckt http://irfaiad.virtualave.net/
Comment: PGP Signed for message verification and/or encryption
Comment: KeyID: 0xD68B61E851046CFD

iQA/AwUBOd0ksNaLYehRBGz9EQJjVQCfUA600RImF5Y7NRoha4BGnHzrV/QAoKWx
9BIcf5UEne847/fTRg/Ryv/y
=CpJ4
-----END PGP SIGNATURE-----


----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to