Transact-SQL (MSSQL) ::

Aggregate Counts

+10 Transact-SQL (MSSQL)

There are two tables, #People and #Pets. Assuming the tables had the following values:

#People
ID FirstName LastName
1 Timothy Khouri
2 Bob Dole
3 Bobby McGee
#Pets
ID PeopleID Kind Name
1 1 Cat Sophie
2 2 Goldfish Goldie
3 2 Dog Spot

... write a query that will yield the following results:

#Sample Result
FirstName LastName PetCount
Bob Dole 2
Timothy Khouri 1