Sql Server 2005 Find Series In Number
I have data in following format 89279 89280 89281 89282 89283 89284 89285 89286 89287 89288 160447 160448 160449 160450 160451 160452 160453 160454 160455 160456 160457 160458 i w
Solution 1:
A standard "gaps and islands" query. SQL Fiddle
WITH T
AS (SELECT *,
YourColumn - DENSE_RANK() OVER (ORDER BY YourColumn) AS Grp
FROM YourTable)
SELECT MIN(YourColumn),
MAX(YourColumn),
COUNT(YourColumn)
FROM T
GROUP BY Grp
Post a Comment for "Sql Server 2005 Find Series In Number"