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 |
|
vision.v1
Yak Posting Veteran
72 Posts |
Posted - 2010-01-23 : 11:47:40
|
| Hi, am using row_number() function, i want to display only those records which have [rownum] = 1 ... wrote something like ::SELECT a.AccountName, TopAmount=t.Amount, row_number() over(partition by AccountName order by AccountName) as [rownum]FROM ACCOUNT aJOIN [transaction] tON a.AccountId = t.AccountIdWHERE [rownum] =1ORDER BY AccountNameBut showing error invalid field [rownum] |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-23 : 11:51:36
|
[code]select * from(SELECTa.AccountName,TopAmount=t.Amount,row_number() over(partition by AccountName order by AccountName) as [rownum]FROMACCOUNT aJOIN[transaction] tONa.AccountId = t.AccountId) as derived_tableWHERE[rownum] =1ORDER BYAccountName[/code] No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|