Skip to content

Instantly share code, notes, and snippets.

@thePunderWoman
Created July 2, 2013 21:21
Show Gist options
  • Save thePunderWoman/5913262 to your computer and use it in GitHub Desktop.
Save thePunderWoman/5913262 to your computer and use it in GitHub Desktop.
All vehicles and their count of t-connectors
select Y.year, M.make, MO.model, S.style,
(SELECT COUNT(*)
FROM VehiclePart VP
INNER JOIN Part P ON VP.partID = P.partID
WHERE VP.vehicleID = V.vehicleID AND P.classID = 11) AS tconnectors
from Vehicle V
INNER JOIN Year Y on V.yearID = Y.yearID
INNER JOIN Make M on V.makeID = M.makeID
INNER JOIN Model MO on V.modelID = MO.modelID
INNER JOIN Style S on V.styleID = S.styleID
ORDER BY M.make, MO.model, Y.year, S.style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment