473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How do i get the previous row data in the same row in sqlserver

Hi All,

I want to get the previous row data in the same row with the new column name by comparing the above row data.

Means that i have a table in sql server with 2 columns.First column name is "ItemCode" and the second column name is "Level".

The second column has numeric data.so i want to compare the second row second column data with the first row second column data.So if the difference is "-1" then add a third column in the output. And in that(third) column i want to show the first row first column data.

like that it will compare all the rows that are present in the table.


I will attach the pictures also for the input and the output so that you all will understand my requirement.

so please anyone show me how to fulfill my requirement.

Thanks In Advance,
Phani Kumar.
Attached Images
File Type: jpg 1.jpg (34.4 KB, 171 views)
File Type: jpg 2.jpg (55.0 KB, 165 views)
Nov 8 '14 #1
1 1318
Rabbit
12,516 Expert Mod 8TB
There's no way to do it unless you have something that defines the link other than position
Nov 8 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jawahar Rajan | last post by:
All, I have a datagrid that I use in a ASP.net web page that loads customer data based on the selected customer ID Some Customers will have no data in the database (which is oracle 9.2) . So I...
0
by: Aaron | last post by:
Hello, I have the first part of the this task done. 13 text boxes and their data in a "databin" that is a textbox. The coding was not too hard--this next part is. I have 7 more textboxes...
3
by: Tee | last post by:
Hi, Anyone know how to redeclare an array with different size but keep the previous data? Just like the redim preserve in VB. Thanks.
8
by: Tee | last post by:
Hi, How do we increase the size of array on runtime and preserve the previous data? I don't want to use ArrayList because the array could be a multi-dimension array. Thanks, Tee
2
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
6
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key...
13
by: staeri | last post by:
I use javascript:history.go(-1) to return to the previous page. I've now found out that when returning to the previous page all selections that the user made in dropdownlists are lost. How can...
7
by: beaudreaux | last post by:
I am needing to calculate a month to date for the previous year in a report. Example: today is 02/18/10 and I have a month to date for today(current year). I need the report to also show month to...
7
by: jpmatthews | last post by:
I need VB code that will automatically pull last month's current data and place it in this month's previous data. We have a form that we use to document meter readings. So for example, when we...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.