Table 1
APPID | CERTID | CERTNAME
--------------------------------
11111 |1|ABCD
22222 |2|EFGH
33333 |3|IJKL
11111 |4|XYZ
44444 |5|JHJ
22222 |6|KJHK
11111 |7|TUHJ
Note:- here cert is is PK and its not repatable where as App Id is repetable columns values
In this table How do I get distinct App Id and corresponding certId ,
This is my query , here still I am getting duplicate AppId's
Select distinct(APPID),CERTID from Table1
Please Please Can any one help me.
Ramesh MaruthiPosted Aug 28, 2014, 11:22 AM
Select CERTID ,APPID
FROM
(
Select CERTID, APPID,
ROW_NUMBER() OVER(PARTITION BY APPID ORDER BY CERTID Asc) rn
From Table1)s
Where rn =1
ORDER BY CERTID
2nd way:
Select MIN(CERTID ) CERTID , APPID
from Table1
Group BY APPID
Dipankar BiswasPosted Aug 28, 2014, 7:19 AM