The long way round?

This SQL works for the problem posed below: SELECT, X.journeys, X.cname FROM (SELECT, COUNT(T.trip_no) AS journeys, AS cname FROM Passenger P, Trip T, Company C, Pass_in_trip PIT WHERE P.ID_psg = PIT.ID_psg AND PIT.trip_no = T.trip_no AND T.ID_comp = C.ID_comp AND NOT EXISTS (SELECT * FROM Trip, Pass_in_trip WHERE Pass_in_trip.ID_psg = P.ID_psg AND… Read More The long way round?

Another SQL puzzle

Once more from which seems to have a phase-of-the-moon related availability. Database is defined as: Database schema consists of 4 tables: Company(ID_comp, name) Trip(trip_no, ID_comp, plane, town_from, town_to, time_out, time_in) Passenger(ID_psg, name) Pass_in_trip(trip_no, date, ID_psg, place) Company table has ID and name of the company, which transports passengers. Trip table has information about trips:… Read More Another SQL puzzle

Relational division again

Take the same relational database tables as before: RESTAURANT(RT_ID, NAME, TYPE, LOCATION) PROXIMITY(RT1_ID, RT2_ID, DISTANCE) USER(U_ID, NAME, EMAIL) REVIEW(U_ID, RT_ID, RT_DATE, RATING, COMMENT) Find the names of the reviewers who reviewed all the restaurants in Earlsfield. In relational algebra: But what about SQL? As I wrote of relational division when I started the blog: one… Read More Relational division again