Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

TSQL Challenge 83 - Compare rows in the same table and group the data

By Jacob Sebastian,

TSQL Challenge 83 - Compare rows in the same table and group the data

The challenge is to compare the data of the rows and group the input data. The data needs to be grouped based on the Product ID, Date, TotalLines, LinesOutOfService. You need to check each row in the table to see if that particular product has the different range of values for TotalLines and Linesoutofservice when compared to the rows below. If yes, then insert that date where a different range is encountered into the "End Date" column. If no change in the values are detected then insert a future date "01/12/2050".

http://beyondrelational.com/puzzles/challenges/117/compare-rows-in-the-same-table-and-group-the-data.aspx

Total article views: 1571 | Views in the last 30 days: 5
 
Related Articles
FORUM

comparing NULLs

comparing NULLs

FORUM

Compare rows in tables

Compare rows in tables

FORUM

compare index

compare index

FORUM

COMPARE QUERY

WOULD LIKE TO COMPARE NEXT RECORD TO PREVIOUS RECORD

FORUM

compare the values in the column

comparing values within the column

Tags
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones