Reputation: 1562
I have a Table which contains duplicate data in one column. I want to display unique data along with the rownum or serial number. my table has fields table1(tno,tname), in where tname has duplicate values, and I want to display the unique 'tname' data.
Upvotes: 2
Views: 1734
Reputation: 29051
Try this:
SET @auto:=0;
SELECT @auto:=@auto+1 rownum, tname
FROM table1 GROUP BY tname
Upvotes: 3
Reputation: 1562
Thanks for your contributions all... I got the answer. If you get the better answer than this just share..
select @rownum:=@rownum+1 sno, a.tname FROM (SELECT DISTINCT tname from Table1) a, (SELECT @rownum:=0) r limit 60
Upvotes: 0
Reputation: 13465
Try this :
Select tname, tno
from table1
group by tname having count(*)=1
Upvotes: 2