Hello,
Some question has already been answered here, but I'm still getting a hard time, maybe you could enlighten me... (First answer: http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/e749bf4a-0a28-4567-8836-acd3cfb656a3/#565332a7-a01f-4b50-9b83-e095cb3be600)
Here's what I have:
100A A 01-01-2013
100A B 02-01-2013
100A C 03-01-2013
200B A 01-01-2013
200B B 03-01-2013
200B C 06-01-2013
What I would want is to have a listing like this:
ProductKey Def DateTime Days DaysSum
100A A 01-01-2013 0 0
100A B 02-01-2013 1 1
100A C 03-01-2013 1 2
200B A 01-01-2013 0 0
200B B 03-01-2013 2 2
200B C 06-01-2013 2 4
The first column would be the datediff between each date, and the second a sum for each productkey.
And in the end I have to export only selected values based on an parameter (let's say at least 3)
I'm using Sql Server 2008.
Thanks.