Question B

0

Please login or register to vote for this query.

(click on this box to dismiss)

Moderators

Q&A for community managers, administrators, and moderators

SELECT COUNT(*)
FROM Users u

-- based on the estimate of 8760 hours per year 
SELECT age.age_range
      ,COUNT(*) as [Count]
FROM(
SELECT CASE WHEN a.AgeYearsIntTrunc < 2 then 'Under 2 Years'
   when a.AgeYearsIntTrunc between 2 and 4 then '2-4'
   when a.AgeYearsIntTrunc between 5 and 9 then '5-9'
   when a.AgeYearsIntTrunc between 10 and 12 then '10-12'
   end as Age_Range
FROM (
    SELECT u.CreationDate
        ,DATEDIFF(hour, u.creationDate,GETDATE())/8760 AS AgeYearsIntTrunc
        FROM Users u ) a ) age
Group By age.age_range

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results