[SQL Server] Prev and Next Row Without RowNumber |
Prev and Next Row Without RowNumber Posted: 16 Jul 2013 12:29 AM PDT Hello All,Can anyone help me with this one.here is the table sample.[code="sql"]---------------------------------------------------------------CREATE TABLE [dbo].[Invoice_t]( [Cost_Center_code] [int] NOT NULL, [Payment_code] [int] NOT NULL, [INV_No] [int] NOT NULL, CONSTRAINT [PK_Invoice_t] PRIMARY KEY CLUSTERED ( [Cost_Center_code] ASC, [Payment_code] ASC, [INV_No] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GOINSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (1, 1, 1)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (1, 1, 2)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (1, 1, 3)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (2, 1, 1)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (2, 1, 2)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (2, 2, 1)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (2, 2, 2)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (1, 2, 1)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (3, 2, 1)INSERT [dbo].[Invoice_t] ([Cost_Center_code], [Payment_code], [INV_No]) VALUES (3, 1, 1)---------------------------------------------------------------[/code]How can i get the previous and next row from this type of data, without using rownumbers.Thanks. |
You are subscribed to email updates from SQLServerCentral / SQL Server 2008 / SQL Server Newbies To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment