Respondido Grouping by age

  • sexta-feira, 23 de março de 2012 09:41
     
     

    Hello, I'm trying to write a SQL command for grouping different age ranges and using them in a chart.

    SELECT Unvan, COUNT(*), FLOOR(DATEDIFF(day, Birthdate, GETDATE()) / 365.25)  AS Yas FROM Personel WHERE Birthdate BETWEEN '01.01.1978' AND '01.01.1989' GROUP BY Unvan, Birthdate

    But this query makes it like below. I want to Combine all those titles and show them like "There is 10 Technician at age 25."

    Title - Count - Age
    Technician 1    25
    Technician 1    25
    Technician 2    24
    Technician 1    24
    Technician 1    24
    Technician 1    24

Todas as Respostas