The task was to write an SQL query that returns the first ever inaugurated president.
The two attributes used from the table administration
should be self-explanatory.
Here you can see my solution which I'm confident in being correct.
SELECT A1.pres_name, A1.year_inaugurated
FROM administration A1
WHERE NOT EXISTS
(SELECT NULL
FROM administration A2
WHERE A1.year_inaugurated > A2.year_inaugurated);
As I'm trying to learn SQL, I thought of any other ways to write this query but couldn't find any.
Are there any other solution that do not use NOT EXISTS
?
But instead use IN
, NOT IN
, EXISTS
?
Another constraint is to not use the MIN
function.
And if there are than one solution that do not use NOT EXISTS
, I would be very happy to see all of them to learn the most from it.