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 |
srujanavinnakota
Starting Member
34 Posts |
Posted - 2011-03-23 : 03:36:19
|
Please help me with select query,I have data in the following format.Id Amt1 182 -143 14 15 436 7.7 1638 3199 47510 35911 16012 61213 -38214 -22315 -243I need select the Id where amt are negative and the previous amounts before them are positive. In the above data, I need select the following. Id Amt2 -1413 -382 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-23 : 04:18:22
|
[code]select *from yourtable twhere t.Amt < 0and exists ( select * from yourtable x where x.Id = t.Id - 1 and x.At > 0 )[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
srujanavinnakota
Starting Member
34 Posts |
Posted - 2011-03-23 : 17:30:16
|
Thank you so much..It worked. |
 |
|
|
|
|