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 |
komeltschenko
Starting Member
4 Posts |
Posted - 2011-02-02 : 12:18:07
|
I have a table with blog entries from all blogs.I have 4 different blogs(BlogID 1-4)I am trying to get the most recent (by date) blog entries 1 for each BlogID. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-02-02 : 12:46:31
|
select Col1, Col2, ...from(select row_number() over (partition by BlogID order by dateCol desc) as rownum,* from yourTable)dtwhere rownum=1 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
komeltschenko
Starting Member
4 Posts |
Posted - 2011-02-02 : 13:17:48
|
SELECT strBlogEntryTitle, StrBlogEntrySummary, dtmBlogEntryUpdatedFROM (SELECT row_number() over (partition by intBlogID ORDER BY dtmBlogEntryUpdated DESC) as rownum, * from TBlogEntries)dt where ronum=1Gives error:Msg 207, Level 16, State 1, Line 10Invalid column name 'ronum'. |
 |
|
komeltschenko
Starting Member
4 Posts |
Posted - 2011-02-02 : 13:18:46
|
opps rownum |
 |
|
komeltschenko
Starting Member
4 Posts |
Posted - 2011-02-02 : 13:21:48
|
It worked thank you sehr viel |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-02-02 : 13:40:09
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|