Reputation: 945
I think this should be a pretty simple question to people who have some experience with database queries
I have a table
Line_ID Run_Date Product_ID Pallet_Cd Run_Qty
1 2012-10-31 01:00:00.000 175 00801004718000000002 0
1 2012-11-28 12:38:01.340 6 00801004718000000003 72
1 2012-11-28 13:32:25.250 4 00801004718000000004 180
1 2012-11-28 17:03:30.937 8 00801004718000000005 72
1 2012-11-29 07:29:58.603 1 00801004718000000006 120
1 2012-11-29 08:03:10.597 6 00801004718000000007 72
1 2012-11-29 08:24:11.370 4 00801004718000000008 180
1 2012-11-30 11:21:56.253 6 00801004718000000009 72
please excuse the formatting but hopefully you can see what the table is supposed to be.
I want to get the next rows after a specific pallet_cd.
For example if i give the parameter a
pallet_Cd = "00801004718000000007"
I just want to bring back the rows for
pallet cd = "00801004718000000007, 00801004718000000008, 00801004718000000009"
Any help with this is appreciated!
Upvotes: 0
Views: 64
Reputation: 5213
If the pallet_Cd
are chronological just ORDER BY Pallet_Cd
and to SELECT TOP 10
WHERE Pallet_Cd >= X
Upvotes: 1
Reputation: 32690
Seems pretty straightforward...
SELECT TOP 10 Line_ID, Run_Date, Product_ID, Pallet_Cd, Run_Qty
FROM YourTable
WHERE Pallet_Cd >= '00801004718000000007'
ORDER BY Pallet_Cd
This will select the next 10 records including the specified pallet code when you order by the Pallet_Cd.
Upvotes: 2