troubleshooting Question

Requesting help with creating an SQL query with 2 tables

Avatar of earwig75
earwig75 asked on
Microsoft SQL ServerMicrosoft SQL Server 2008SQL
6 Comments1 Solution102 ViewsLast Modified:
I have 2 tables, the first table (tblCarTypes) has 2 columns, CarTypeID and CarType. The 2nd table (tblCarRecords) has some records, where one of the columns is the CarType (which is populated with the CarTypeID). I want to create a query that will output a count of records from carRecords for each CarType. Samples of the data for each table is below.

The output I would like based on the sample data below would be like this below example. Could someone assist?

This is what I want the query to output:
CarType  |  Count
suv          |  3
pickup    |  3
compact | 1


tblCarTypes:
CarType    |   CarTypeID
suv            |         1
pickup       |         2
compact    |         3


tblCarRecords:
Date     |  CarType  |  ID
3/2/15   |    1           |   1
3/3/15   |    1           |    2
3/4/15   |    1           |    3
3/4/15   |    2           |    4
3/4/15   |    2           |    5
3/4/15   |    2           |    6
3/4/15   |    3           |    7
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros