Let's say you have an employee table that contains their hire date. Would it be possible to, in one query, get a count of all the employees that have been working 12 months or less, between 12 and 36 months, between 36 and 60 months etc etc.....
I could use this query to count all the employees who were hired less than 12 months ago, but how could I join other derived queries
select count(EmpID) as LT_One
from payroll_employees
where hired > = dateadd(mm, -12, getdate())
There is a field in the table that happens to be the same for every employee because it's not used, so I used that as the basis to join the drived tables, but it got me to wondering if there was a more elegant way. I couldn't think of any.
I could use this query to count all the employees who were hired less than 12 months ago, but how could I join other derived queries
select count(EmpID) as LT_One
from payroll_employees
where hired > = dateadd(mm, -12, getdate())
There is a field in the table that happens to be the same for every employee because it's not used, so I used that as the basis to join the drived tables, but it got me to wondering if there was a more elegant way. I couldn't think of any.