I'm suppose to select number of trips completed by plane TU-134. I'm doing basic exersices on some website.
SELECT plane, COUNT(trip) as numberOfTrips FROM Pass_in_trip
INNER JOIN Trip WHERE plane = 'TU-134'
This prints
plane TU-134 numberofTrips 128
But its still not correct why? I assume im not getting the completed trips?
CodePudding user response:
You need to fix your inner join statement and group data by plane so you can use count function.
SELECT
Plane = T.plane,
NumberOfTrips = COUNT(P.trip)
FROM Pass_in_trip P
INNER JOIN Trip T ON P.Trip= T.Id
WHERE
T.plane = 'TU-134'
GROUP BY
T.plane