SELECT *
FROM Trips T1
WHERE T1.Cost NOT IN (SELECT T2.Cost FROM Trips T1, Trips T2 WHERE T1.Cost > T2.Cost)
This is currently my query that will return the most expensive trip listed in the itinerary. Of course, you can simply use MAX, but I have been instructed not to.
This is the query I have figured out that returns what I want. In the Trips table, it features the TripId, StateofTrip (ie MA, NC, PA), TravelMethod (Car, Train, Bus), and the Cost. So output may look like
987 CA Plane 2000
What I'm wondering is if there is a way to do this in a Self Join, not a nested subquery. So something that starts like this...
SELECT *
FROM Trips T1, Trips T2
....
Is this possible to do without using MAX explicitly? How can I compare values in a self-join and return the singular max?
Additionally, in the first query, can someone explain the nested example? I don't really understand how NOT in returns the desired result.