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 |
|
mlawton40
Starting Member
15 Posts |
Posted - 2007-05-16 : 05:59:58
|
| Hi I have the following table with the following columns:TransferRequestTransferRequestIdOrderLineIdStatusSiteRequestedRequestUsernameRequestDateTimeNow I would like to make a select statement that selects all where the OrderLineId = 23 and the RequestDateTime is the most recent.Any ideas? and I would be very gratefull, been trying to do this for ages now.Cheers, Mark |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-16 : 06:02:12
|
[code]select t.*from table tinner join ( select OrderLineId, TransferRequest = max(TransferRequest) from table group by OrderLineId) ron t.OrderLineId = r.OrderLineIDand t.TransferRequest = r.TransferRequestwhere t.OrderLineId = 23[/code] KH |
 |
|
|
|
|
|