Say I have this table:
EMPLOYEES
----------------------------------------------------------
first last ID hire terminated wage
------ --------- --- ---------- ----------- ----
Ruth Halburg 1 2010-05-15 2017-03-01 2000
Sally Hallson 2 2010-08-20 NULL 5000
Merry Hallway 3 2011-01-24 NULL 3000
and I need to get the difference in days between the max 'hire' date and min 'hire' date of employees still working in the company (terminated = NULL).
I know I need to use something like
Select *, datediff(d, max(hire), min(hire) as Difference
From Employees
Where terminated = NULL
but i'm not sure how to get it to work.