Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 get top distinct record that really isn't distinct

Author  Topic 

Vivaldi
Constraint Violating Yak Guru

298 Posts

Posted - 2001-04-24 : 13:11:58
Hey all,

Back with a confusing query that I have never got to work, (asked back a few weeks, but dead ends)

Basically, I have tried a ton of stuff, but i am confused, more so than when i started which means its almost miller time.

I need to grab one record for each residentid in the table, (can be many) ordered by level, (can be multiple records for 1 residentid with same level)

in end, all I want is the literal,count(residentid)
grouped by literal (shows new criminals for some time frame, by literal)

i have a table of OFfense
has identity of offenseid(id)
residentid is PK of diff't table (foreign key)
literal is an id of another table
level is a column that specifies the order

ID | residentid | literal | level


so if residenti "85" has 3 records
99|85|98980|F
70|85|43434|G
88|85|35353|F

I only want one of the "F" records to be counted.

Any ideas at all, I have tried just about everything I know, and I am lost.

Thanks for the help.

Software Composer
   

- Advertisement -