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
 select distinct after one record

Author  Topic 

bebe11
Starting Member

1 Post

Posted - 2012-03-07 : 16:30:08
hello,
it is posible to make distinct after some records?

for example i have this table
Module Multiple
77db88991 da
77db88991 da
77de66543 da
77de66543 da
77se54321 nu
77dw23123 nu
77db88991 nu

and i need a select distinct module, multiple only when multiple is 'da', and when multiple is 'nu' to receive all rest of the row

results should be:

77db88991 da
77de66543 da
77se54321 nu
77dw23123 nu
77db88991 nu
many thanks for any suggestion!

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-07 : 18:43:31
[code]SELECT DISTINCT
Module, Multiple
FROM
YourTable
WHERE
Multiple = 'da'
UNION ALL
SELECT
Module, Multiple
FROM
YourTable
WHERE
Multiple <> 'da';[/code]
Go to Top of Page
   

- Advertisement -