Skip to content
Advertisement

Is it possible to select a distinct column and get another column’s value count? [closed]

I think I might know enough to do parts individually but is it possible to do it with one statement? I need to display a model count for each year it appears in.

I have the following data:

It should come out something like:

How do I accomplish this in SQL? Is it a group by year and count the models?

Advertisement

Answer

Unless I’m overlooking something, you just need to GROUP BY the two columns you’re interested in. I changed the name of the last column to avoid any keyword issues.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement