﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Sequencing / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 23:29:38 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Sequencing</title><link>http://www.sqlservercentral.com/Forums/Topic515092-338-1.aspx</link><description>Well done.  :)</description><pubDate>Wed, 11 Jun 2008 07:06:12 GMT</pubDate><dc:creator>Kent Waldrop</dc:creator></item><item><title>RE: Sequencing</title><link>http://www.sqlservercentral.com/Forums/Topic515092-338-1.aspx</link><description>Hi Kent,Thanks for your help, I've managed to get it work using the ROW_NUMBER and partition by clause.</description><pubDate>Wed, 11 Jun 2008 06:58:15 GMT</pubDate><dc:creator>David-155102</dc:creator></item><item><title>RE: Sequencing</title><link>http://www.sqlservercentral.com/Forums/Topic515092-338-1.aspx</link><description>Please give a look at the "ranking" functions such as "row_number()" and "rank()" in books online.  Pay particular attention to use of the OVER() clause in conjunction with both the PARTITION BY and ORDER BY clauses.Kent</description><pubDate>Wed, 11 Jun 2008 06:09:55 GMT</pubDate><dc:creator>Kent Waldrop</dc:creator></item><item><title>Sequencing</title><link>http://www.sqlservercentral.com/Forums/Topic515092-338-1.aspx</link><description>Is it possible to add a sequence number to rows such that it resets on the start of each grouping? For example, using the following code:[code]create table myTable (sales_person varchar(10), model varchar(10), date_sold datetime)insert into myTable (sales_person, model, date_sold)values ('David','A', cast('2008-01-01' as datetime))insert into myTable (sales_person, model, date_sold)values ('David','A', cast('2008-01-02' as datetime))insert into myTable (sales_person, model, date_sold)values ('David','A', cast('2008-01-03' as datetime))insert into myTable (sales_person, model, date_sold)values ('Fred','A', cast('2008-01-01' as datetime))insert into myTable (sales_person, model, date_sold)values ('Fred','A', cast('2008-01-04' as datetime))insert into myTable (sales_person, model, date_sold)values ('Fred','A', cast('2008-01-06' as datetime))select * from myTabledrop table myTable[/code]I would like the results to be:1, David, A, 2008-01-012, David, A, 2008-01-023, David, A, 2008-01-031, Fred, A, 2008-01-012, Fred, A, 2008-01-043, Fred, A, 2008-01-06Note that the first column (the sequence number) is reset upon each group being the sales_person and potentially the model in this example.Thanks</description><pubDate>Wed, 11 Jun 2008 05:59:54 GMT</pubDate><dc:creator>David-155102</dc:creator></item></channel></rss>