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 |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2008-09-10 : 19:20:22
|
| I am passing orderid to my select, How to get the previous order id from my table orders.I am passing orderid = 155, now ould like to get the previous records orderid. it could be any number lower than 155....select prev(orderid) from table_orders where orderid=@orderidplease help thank you very much for the information.. |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-09-10 : 19:30:50
|
| what are u using to pass this record ? IF a SPlook into the scope_identity()declare @previous intset @previous = scope_identity() |
 |
|
|
hey001us
Posting Yak Master
185 Posts |
Posted - 2008-09-10 : 19:33:02
|
| select top 1 orderid from table_orders where orderid=@orderidorder by orderid deschey |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-09-11 : 05:29:10
|
| orselect max(orderid) from table_orders where orderid<@orderidorder by orderid descMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|