0

I've seen a few of these types of questions on stackoverflow, but they don't quite fit in with my question:

Is this a valid query to see the average difference in days between two dates from two datetime columns?

SELECT AVG(DATEDIFF(DATE(datetime_column1),DATE(datetime_column2)))
FROM table_name
WHERE status = 2

Further, I am wanting to group by another column, e.g.

SELECT AVG(DATEDIFF(DATE(datetime_column1),DATE(datetime_column2))),grouping_column
FROM table_name
WHERE status = 2
GROUP BY grouping_column
Drewdavid
  • 3,071
  • 7
  • 29
  • 53

0 Answers0