Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
How to SQL to display as follow,applicantIdx kursusIdx subjectCd merit-2147454057 209 16 8-2147454057 225 16 8-2147454057 230 16 8-2147454057 237 16 8-2147454057 242 16 8
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-05-11 : 14:24:12
Many different ways to do it. Here are couple of those:
SELECT applicantIdx, kursusIdx, subjectCd, merit FROM @t1GROUP BY applicantIdx, kursusIdx, subjectCd, merit;
SELECT applicantIdx, kursusIdx, subjectCd, meritFROM( SELECT *, ROW_NUMBER() OVER (PARTITION BY applicantIdx, kursusIdx, subjectCd, merit ORDER BY (SELECT NULL)) AS RN FROM @t1)sWHERE RN = 1;
Delinda
Constraint Violating Yak Guru
315 Posts
Posted - 2012-05-11 : 14:29:59
tq sunita
vijays3
Constraint Violating Yak Guru
354 Posts
Posted - 2012-05-12 : 09:30:18
[code]One More waySELECT DISTINCT applicantIdx,kursusIdx,subjectCd,merit FROM YourTable[/code]Vijay is here to learn something from you guys.
vijays3
Constraint Violating Yak Guru
354 Posts
Posted - 2012-05-12 : 09:34:23
[code]Another way ;with cte as ( SELECT *, ROW_NUMBER() OVER (PARTITION BY applicantIdx, kursusIdx, subjectCd, merit ORDER BY (SELECT NULL)) AS RN FROM #TEMP)delete from cte WHERE RN > 1;[/code]Vijay is here to learn something from you guys.