We help IT Professionals succeed at work.

SQL statement

Olin
Olin asked
on
hello, i have simple table Friends order by Age :

Name     Age
Johnny   17
Bobby    17
Angela   17
Olin     18
Harris   18
Bennet   19

now i need SQL statement to count total age that should display 3 records :

3   (total of age 17)
2   (total of age 18)
1   (total of age 19)

how the SQL statement?
Comment
Watch Question

Commented:
"SELECT Count(tblOne.name) AS TotalAge, tblOne.age
FROM tblOne
GROUP BY tblOne.age;"

thats it
TimCotteeHead of Software Services
CERTIFIED EXPERT

Commented:
Select Age,Count(Age) From MyTable Group By Age

Commented:
Using 'group by' means the table doesn't _have_ to be sorted first.
Select ('Total no. of people with age'+Age+' are '+count(age)) AS TotalAges from Friends group by Age

Explore More ContentExplore courses, solutions, and other research materials related to this topic.