Groups | Blog | Home
all groups > sql server mseq > september 2003 >

sql server mseq : Pulling 2 responses per user


Will
9/15/2003 2:01:38 PM
Pulling data from an Oracle Server and creating a temp
table(User, Response, ResponseDate). Have 75 unique users,
and over 10,000 responses and the date submitted. How do I
limit the results to only two distinct responses per user
with dates? TOP 2 does not work, SELECT DISTINCT does not
either.

Any help on the right path would be greatly appreciated.

Will
Will
9/15/2003 2:58:43 PM
Thanks for the help. Works perfectly.

Will
[quoted text, click to view]
Anith Sen
9/15/2003 4:13:31 PM
Do:

SELECT *
FROM tbl
WHERE (SELECT COUNT(col)
FROM tbl t1
WHERE t1.user = tbl.user
AND t1.col <= tbl.col ) <= 2 ;

--
- Anith
( Please reply to newsgroups only )

AddThis Social Bookmark Button