I have a table with data:
id a_no accountname
1 NULL ac1
1 234 ac2
1 567 ac3
2 NULL ac4
I want to select row with the following criteria:
- if same id exist in more than 1 row, then remove the row with
a_no=NULL - if id exist in 1 row only, keep that row unchanged
So that the resulting rows should be
id a_no accountname
1 234 ac2
1 567 ac3
2 NULL ac4
How to write the T-SQL query? Thanks.
1 Answer