New Query (Urgent!!)
Hi All ,
Anyone help me to write the query :)
****************************
Id | AccountNo.|Status
****************************
1 | A10000 |Y
****************************
1 | A20000 |Null
****************************
1 | A30000 |Null
****************************
2 | B10000 |Null
****************************
2 | B20000 |Null
****************************
2 | B30000 |Null
****************************
3 | C30000 |Null
****************************
3 | C20000 |Null
****************************
3 | C10000 |Null
****************************
4 | D10000 |Null
****************************
5 | E10000 |Y
I want to retrieve (ID ,AccountNo.and Status)
Conditions-
1-->if with particular Id there is "Y" and "Null" i want to retrieve only "Y" records
(i.e in above case 1,A10000,Y)and (5,E10000,Y)
2-->if with particular Id there is no "Y" ,then i want to retrieve only first records with status "Null" records
(i.e in above case 2,B10000,Null) and (2,C30000,Null)Note here C3 comes before C1.
Depending on above table i want to write query that can return following table
****************************
Id | AccountNo.|Status
****************************
1 | A10000 |Y
****************************
2 | B10000 |Null
****************************
3 | C30000 |Null
****************************
4 | D10000 |Null
****************************
5 | E10000 |Y
Awaiting for your reply
Cheers :)
vinod
__________________
Cheers :)
vinod
|