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
 Remove repetitive data

Author  Topic 

winza
Starting Member

2 Posts

Posted - 2009-10-23 : 15:16:52
I have written one store proc which has joins and gets data from other table will return some 1000 rows which has repetitve data .I need to remove these repetive rows..i tried distinct,copying data to temp table and display only distict rows and 'group by' nuthin worked out..is there any way to display one unique records..

say for eg:

id status
24568 Pass
0367 Fail
24568 Fail
0214 Pass
24568 Pass

If u notice this 24568 repeats 3 times and also i need to display if it has atleast one status :Pass that id i have to display it as pass not the other.Any help will be appreciated.
Thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-10-23 : 15:28:24
Try this:
This assumes that 'pass' and 'fail' are the only two possible status. if an id exists with a 'pass' then pass will be returned as status.

select id, max(status) as status
from <yourTable>
group by id

Be One with the Optimizer
TG
Go to Top of Page

winza
Starting Member

2 Posts

Posted - 2009-10-23 : 15:37:34
TG Awesome!!!! that was really quick response and it worked as charm...Thank you so much!!!!!!!!!!
Go to Top of Page
   

- Advertisement -