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.
| Author |
Topic |
|
hspatil31
Posting Yak Master
182 Posts |
Posted - 2011-12-18 : 21:56:15
|
| Dear All,I have following query, So I am getting output top 1 subject whose EMPID is 100(With empid there is multiple records that's why IO have given TOP 1 in select statement). But I want If I will not give the where condition only one subject should shows for every EMPID. Anyone one record from multiple records with specific EMPID.Can anybody please tell me how to do this ?Query:SELECT TOP 1 SUBJECT FROM EMPLOYEE WHERE EMPID = '100'Thanks and Regard'sHarish Patil |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-18 : 22:11:50
|
[code]select *from( select *, row_no = row_number() over (partition by EMPID order by SUBJECT) from EMPLOYEE)twhere t.row_no = 1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|