sql - How to remove certain rows if there are two values for same login id -


loginid       status ======================== jo            deleted jo            active jo            discard kir           active user1         active user1         deleted 

the results shoud give me

kir      active 

rest login id should not there.

can plesase query

this should trick:

select * yourtable loginid in (select loginid  yourtable  group loginid  having count([status]) = 1)  

the having clause ensures loginid values have single status mapped them selected. note query select required rows. if want delete offending rows, can so:

delete  yourtable loginid in (select loginid  yourtable  group loginid  having count([status]) > 1) 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -