oracle - SQL Query to output present guests in hotel -
Consider the above relationships I am trying to list all the guests and dependents who currently live in the hotel. , Which means that they are present in the room.
Here is my SQL query:
g.FORENAME, g.SURNAME select from guest g at g.GUESTID = b.GUESTID where (b h. DEPARTDATE & gt; TO_CHAR (CURRENT_DATE, 'DD-Mon-YYYY') and b.ARRIVEDATE & LT; TO_CHAR (CURRENT_DATE, 'DD-Mon-YYYY')) UNION jOIN selection d.FORENAME, dependent d interiors BOOKINGDEPENDANT select bd d.SURNAME on bd.DEPENDANTID = d.DEPENDANTID about where booking b (in bd.BOOKINGID b.BOOKINGID to (b.DEPARTDATE & gt; TO_CHAR (CURRENT_DATE, 'DD-Mon-YYYY') and b. ARRIVEDATE & TO; TO_CHAR (CURRENT_DATE, 'DD-Mon-YYYY'))); Performs the query, but shows no rows when it is considered. Here bookings . Include booking values (2002, 5445, '19-MAR-2013 ', '10 -JUN-2013', 250.00); Insert in booking prices (2004, 3005, '19-MAR-2013 ', '21-March-2013', 250.00); Despite the guests 5445 and 3005 where their affiliate bookings are located, no output is being displayed. I'm looking for names of 5445 and 3005.
If I extract the following lines:
b.ARRIVEDATE & lt; TO_CHAR (CURRENT_DATE, 'DD-MON-YYYY') A list of names will be displayed. But the logic is wrong because without discussions you will not be able to find existing guests.
Have you mixed up the question above in my wrong way? Why are they not displaying those guests when they are fulfilling the condition they are all present guests? What can I do?
I think the issue is that you are comparing the wire instead of the stars.
'19-March-2013' & lt; '21-Mar-013 '= & gt; TRUE '10 -JUN-2013 '& gt; '21-Mar-013 '= & gt; Incorrect (& lt; '21 ... ') as the '10 ...' Place your database in the form of dates. Alternatively, to replace them for YYYY-MM-DD, if you need to compare them in the form of text (such as string compare date comparison, need to be done as
note : Although the correct solution is to replace your columns, there is a correct version of the below given information (though somewhere near efficient / correct), which will work with the text column: Select
Please join g.GUESTID = b.GUESTID Booking B at guest village intern from g.FORENAME, g.SURNAME where TO_DATE (b.ARRIVEDATE, 'DD-Mon-YYYY') and TO_DATE (b.DEPARTDATE, 'DD- Mon-YYYY ') CURRENT_DATE between UNION SELECTION D. FORENAME, D. Suranam Defendant D Inner Join Bucking Dependent BD On BD. Defendant = D. Dependentants where BD. Booking ID (Selection B.BikingId Booking B, where TRANDITICITY (BRIVEDAD, DD-MAN-Y YYY) and TO_D ATE (B.Dpartatid, 'DD-Mon-YYYY');
Comments
Post a Comment