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
 General SQL Server Forums
 New to SQL Server Programming
 Reporting - Display Distinct Value

Author  Topic 

paganini
Starting Member

2 Posts

Posted - 2007-01-22 : 14:55:39
How do I display only those rows with single occurance value in the LID column?

Original table:
SID | LID
94 | 2
222 | 2
130 | 3
82 | 4
99 | 5
161 | 5
103 | 6
161 | 7
99 | 7
103 | 8

Desired output:

SID | LID
130 | 3
82 | 4
103 | 6
103 | 8

Thanks in advance!

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-01-22 : 15:32:48
[code]
select
SID = Max(SID),
LID
from
MyTable
group by
LID
having
count(*) = 1
order by
LID
[/code]

CODO ERGO SUM
Go to Top of Page

paganini
Starting Member

2 Posts

Posted - 2007-01-22 : 17:07:49
Perfecto! Thanks very much Michael.
Go to Top of Page
   

- Advertisement -