How to get the null and non null records from the table?
Posted on 2008-06-26
I have one table sample_table. It contains the records like below. This is just sample table
ID PAR_ID NAME SURNAME
100 1000 SURI
200 1000 RAJ XXX
300 1000 SURIYA
The above sample table contains some sort of records. I want to get the records if the surname column is not null i should return that not null row for that particular PAR_ID. If the SURNAME column is null, I should return any one of the row from table for that particular PAR_ID. For example the above table contains the XXX record in SURNAME column. So that column does not contain null value. So i need to return that XXX row from the table for that particular PAR_ID. But if that XXX is not avaiable, all the rows are null for that column, i need to return any of the row from that table for particular PAR_ID.
For this we have to write SQL query. Can anyone share with me if you get something.