Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Hus
Starting Member
4 Posts |
Posted - 2011-06-23 : 13:18:34
|
Can someone please assist me this? I 'm creating a spell episode date however the dates are overlapping.E.gDataid Seqno Start date Enddate123 2 01/04/2007 to 05/05/2007123 2 10/10/2008 to 20/12/2008123 2 18/12/2008 to 01/02/2009123 2 01/03/2009 to123 2 04/04/2009 to 05/05/2009156 3 01/01/2011 to 03/03/2011160 3 01/01/2011 How would I do the query which will show me result as 123 01/04/2007 to 05/05/2007. Spell 1123 10/10/2008 to 01/02/2009 Spell 2123 01/03/2009 to 05/05/2009 Spell 3156 01/01/2011 to 03/03/2011 Spell 1160 01/01/2011 Spell 1 |
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-06-24 : 03:10:54
|
SELECT id ,Seqno, Start date, Enddate, ROW_NUMBER() OVER (PARTITION BY id ORDER BY Start) AS SpellFROM YourTable--------------------------http://connectsql.com/ |
 |
|
|
|
|