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 |
|
alexmarshuk
Starting Member
12 Posts |
Posted - 2009-07-01 : 09:11:15
|
| hi Guys, I have the sql below. Im fairly new to this but I want to return the latest (by time_stamp) row but have only one record returned per agent_id.. hope that makes senseORDER BY agent_id DESC |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-07-01 : 09:13:06
|
[code]SELECT agent_id, time_stamp, status, unav_reason_idfrom ( SELECT agent_id, time_stamp, status, unav_reason_id, row_number() over (partition by agent_id order by time_stamp desc) AS recid FROM agt_avail_act WHERE agt_grp_id = '15' ) AS dwhere recid = 1[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
|
alexmarshuk
Starting Member
12 Posts |
Posted - 2009-07-01 : 09:18:08
|
| magic! cheers mate!! |
 |
|
|
|
|
|