Repeat exercise 11, but this time list only hiking tips in the state of New Hamp
ID: 3849087 • Letter: R
Question
Repeat exercise 11, but this time list only hiking tips in the state of New Hampshire (NH), list each trip only once, and sort the results in descending order by trip name.
Question 11. Find the trip name of all reservations for hiking trips and sort the results by trip name in ascending order.
SQL Code for Q11:
SELECT DISTINCT TRIP_NAME
FROM RESERVATION, TRIP
WHERE RESERVATION.TRIP_ID = TRIP.TRIP_ID
AND TYPE ='Hiking'
Order by TRIP_NAME;
Having trouble getting the SQL code right for Q18
using textbook A Guide to SQL 9th edition and oracle application express to run the SQL code
Explanation / Answer
You need to add the fileter for state in where clause as STATE = 'NH', and to sort by descending order, need to put a desc after order by.
SELECT DISTINCT TRIP_NAME
FROM RESERVATION, TRIP
WHERE RESERVATION.TRIP_ID = TRIP.TRIP_ID
AND TYPE ='Hiking'
AND STATE = 'NH'
Order by TRIP_NAME desc;