0

I have a table with the following data

ProductID          StartDate     EndDate
TT1                1 May 2013    10 May 2013
TT1                8 May 2013    14 May 2013
TT2                6 May 2013    12 May 2013
TT2                8 May 2013    12 May 2013

The result needs to show the following count

TT1               14  (Note this is the 10 days from the 1 record and the 11,12,13,14 May)
TT2               7   (Note this for the 6-12 rec
Srini V
  • 11,045
  • 14
  • 66
  • 89

1 Answers1

0
    SELECT productID,DATEDIFF(MAX(endDate),MIN(startDate))+1 DAYS FROM
   db.new_table GROUP BY productID
Lijo
  • 6,498
  • 5
  • 49
  • 60