-2

I have the following table:

ticket    arrivaltime        resolution time    status

t1        '2012-09-03'        null               new
t2        '2012-09-04'        null               new
t1        (can be anything)   '2012-09-14'       verified    
t1        (can be anything)   '2012-09-16'       verified
t2        (can be anything)   '2012-09-06'       verified

Now I want to find, for example, for t1 the difference in days:

Age(t1)=(resolution time of last entry) - (arrival time of first entry)

Similarly I'll find it for t2.

How can I find this?

ronalchn
  • 12,225
  • 10
  • 51
  • 61
Bhavik Shah
  • 5,125
  • 3
  • 23
  • 40

2 Answers2

0

You can do something like:

SELECT TICKET, DATE_DIFF(MAX(RESOLUTION_TIME) - MIN(ARRIVAL_TIME)) AS DIFF FROM TABLE GROUP BY TICKET
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
0

Refer the following link regarding syntax

Date Difference in MySQL to calculate age

SELECT TICKET, DATE_DIFF(MAX(RESOLUTION_TIME),MIN(ARRIVAL_TIME)) From TABLE 
Community
  • 1
  • 1
Freelancer
  • 9,008
  • 7
  • 42
  • 81