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 |
elic05
Yak Posting Veteran
62 Posts |
Posted - 2011-11-28 : 20:18:51
|
select Id,CategoryId,VoteUntill,Question,UserNamefrom (select *, seq = row_number() over (partition by CategoryId order by VoteUntill desc)from post) where seq < 5 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-11-28 : 20:20:02
|
[code]select Id,CategoryId,VoteUntill,Question,UserNamefrom (select *, seq = row_number() over (partition by CategoryId order by VoteUntill desc)from post) AS dwhere seq < 5[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
elic05
Yak Posting Veteran
62 Posts |
Posted - 2011-11-28 : 20:22:25
|
greate,thankseven though I dont understand why, but it works |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-11-28 : 20:23:02
|
the "d" is the alias name given to the derived table KH[spoiler]Time is always against us[/spoiler] |
|
|
jassi.singh
Posting Yak Master
122 Posts |
Posted - 2011-11-30 : 01:59:59
|
hi,you are just giving alias name to a derived tableselect Id,CategoryId,VoteUntill,Question,UserNamefrom (select *, seq = row_number() over (partition by CategoryId order by VoteUntill desc)from post) AS dwhere seq < 5 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-12-01 : 06:32:21
|
quote: Originally posted by elic05 greate,thankseven though I dont understand why, but it works
It is becuase unlike ORACLE, SQL Server needs a alias name for the derived tableMadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|