I am in a college system development class, and we are using SQLPlus with some tables and data loaded to answer questions with SQL statements. I am stuck on a few questions. I was able to answer 30 of the 40 using the references. The questions have gotten very difficult in my opinion now. I write the statements, but I am not getting what the question asks for. Here is one that I am stuck on now. Here is the tables, so you know what fields there are to select from.
The question wants - the people's name with reservations, flight numbers, reservation date, and the flight date for all reservations between 30 and 60 days in advance in 2002. The professor wants us to join the reservation.confirm_no to the ticket.Itinerary_no. Make it a select distinct query to keep it to 22 rows coming back.
I am getting the reservation date after the flight date with my statement. I wrote
SELECT DISTINCT reservation.res_date, reservation.Res_name, ticket.flight_date, ticket.flight_d
ate-30 AS "ADVANCE NOTICE"
2 FROM reservation, ticket
3 WHERE ticket.itinerary_no=reservation.confirm_no
4 AND reservation.res_date > '01-JAN-02'
5 AND reservation.res_date < '01-JAN-03';
Originally posted by amesjustin
Well, I doubt anyone will do all the work for you, but if all you are looking for is pointers....
Take a look at the BETWEEN command.
I wouldn't want anyone to the work. I have tried a between and couldn't figure how to get the statement to reflect between 30 and 60 days. How do you set up the statement to minus the thirty or sixty? I tried to To_char but my resources did not have good examples.
I have tried a "between" but which variables would it be best to use it on or can you use two? We have had a real quick lesson on SQL. It is an Internet class so seeing the teacher is through emails. I put my statement of what I wrote at the very bottom. I was asking for pointers on my statement. I guess I get confused since there is two or three variables I am looking at. 1) all reservations in 2002 with 30 to 60 days reserved in advance, 2) setting it to be between Jan 1 and Dec 31 3) getting a number back on how many days it was too.
The "between" examples I saw usually followed the "where" and my "where" items are comparing an itinerary number and confirmation number. I like learning SQL but have noticed it is like java and any small detail can through it off like comma, period, paranthesis, and etc...
I have worked on this one problem over six hours. That is why I decided to enlist a discussion group for help. Thanks.