SNO MOBILE NAME
1 8987654321 RAJUVARDHAN
2 8987654321 PRANAYE KUMAR
3 8987854321 VAMSHIDHAR
4 9014494875 SHASHI
5 9014494875 SUVARNA VARMA
6 9014494875 MEENAREDDY
7 9866029162 JANSIVARMA
8 9866029162 PRAGATHIVARMA
9 9866029162 SAMBA VARMA
I Want output like this...
select distint mobile and second name only
like this
SNO MOBILE NAME
1 8987654321 PRANAYE KUMAR
4 9014494875 SUVARNA VARMA
7 9866029162 PRAGATHIVARMA
Javeed M ShaikhPosted Apr 30, 2013, 2:01 PM
the below query should take care of duplicate Mobile or single Mobile
chetan tembhrePosted Apr 30, 2013, 3:13 AM
Try below query,
with CTE as(select row_number() over(partition by Mobileno order by mobileno) row,
Jignesh TrivediPosted Apr 29, 2013, 11:36 PM
Javeed solution is good.
is there any requirement like if table is containing only single value of mobile number in table than you query must return first value else second value?
in this case above solution is fail to retrieve the record.
Javeed M ShaikhPosted Apr 29, 2013, 2:18 PM