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 |
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2008-09-10 : 00:07:39
|
| Hello All,I have a query which gives me multiple rows result.and I have a field Status which will be 'T' for only one record in the whole result set.I just want to get 1 previous row from Status=TSample DataID Amount Status1 1000 N2 500 N3 700 T4 800 N5 500 NHere my requirement is to fetch 1 previous record Where Status=Tmeans I want to get where Amount=500 and ID=2 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-10 : 00:09:37
|
is the ID in running sequence ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2008-09-10 : 00:12:22
|
| No I don't know the ID on the time of query and it can be manupulated by user , it is not auto generated. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-09-10 : 00:17:28
|
[code]select top 1 *from SampleDatawhere ID < (select ID from SampleData where Status = 'T')order by ID desc[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|