0% found this document useful (0 votes)
14 views3 pages

Dbms Lab2

Uploaded by

dpaul.code
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Dbms Lab2

Uploaded by

dpaul.code
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

mysql> select * from Hotel;

+---------+----------------+----------+
| hotelno | name | city |
+---------+----------------+----------+
| 1 | Vivanta_By_Taj | Banglore |
| 2 | ITC_Gardenia | London |
| 3 | KingsFort | London |
| 4 | Amber | London |
| 5 | HillView | Banglore |
| 6 | KailashIn | Banglore |
+---------+----------------+----------+
6 rows in set (0.00 sec)

mysql> select * from Room;


+--------+---------+--------+-------+
| roomno | hotelno | type | price |
+--------+---------+--------+-------+
| 101 | 1 | single | 244 |
| 102 | 1 | single | 305 |
| 103 | 1 | double | 486 |
| 104 | 1 | double | 548 |
| 201 | 2 | double | 425 |
| 202 | 2 | double | 365 |
| 203 | 2 | family | 425 |
| 301 | 3 | double | 244 |
| 302 | 3 | double | 305 |
| 303 | 3 | family | 669 |
| 401 | 4 | double | 457 |
| 402 | 4 | family | 730 |
| 403 | 4 | family | 791 |
| 501 | 5 | family | 183 |
| 502 | 5 | family | 273 |
| 503 | 5 | family | 340 |
| 601 | 6 | single | 305 |
| 602 | 6 | double | 329 |
| 603 | 6 | family | 353 |
+--------+---------+--------+-------+
19 rows in set (0.00 sec)

mysql> select * from Guest;


+---------+-----------+--------------+
| guestno | guestname | guestaddress |
+---------+-----------+--------------+
| 14001 | Akash | Bilaspur |
| 14002 | Raghuveer | Bhilai |
| 14003 | Shreyansh | Raipur |
| 14004 | Surya | Mahasamund |
| 14005 | Swapnil | Bilaspur |
| 14006 | Vishal | Baniyapara |
| 14007 | Riya | Delhi |
| 14008 | Garmia | Rajnandgaon |
| 14009 | Suruchi | Bhilai |
| 14010 | Tripti | Dhamtari |
+---------+-----------+--------------+
10 rows in set (0.00 sec)

mysql> select * from Booking;


+---------+--------+---------+------------+------------+
| hotelno | roomno | guestno | datefrom | dateto |
+---------+--------+---------+------------+------------+
| 1 | 101 | 14003 | 2019-02-12 | 0000-00-00 |
| 1 | 102 | 14005 | 2019-02-11 | 2019-02-12 |
| 1 | 104 | 14006 | 2019-02-11 | 2019-02-11 |
| 2 | 201 | 14004 | 2019-02-11 | 2019-02-13 |
| 2 | 203 | 14001 | 2019-02-10 | 0000-00-00 |
| 3 | 303 | 14002 | 2019-02-10 | 2019-02-11 |
| 4 | 402 | 14007 | 2019-02-01 | 0000-00-00 |
| 5 | 501 | 14006 | 2019-02-04 | 0000-00-00 |
| 6 | 602 | 14009 | 2019-02-07 | 2019-02-09 |
| 6 | 603 | 14010 | 2019-02-06 | 0000-00-00 |
+---------+--------+---------+------------+------------+

mysql> select roomno,hotelno,type,price*1.05 from Room;


+--------+---------+--------+------------+
| roomno | hotelno | type | price*1.05 |
+--------+---------+--------+------------+
| 101 | 1 | single | 256.20 |
| 102 | 1 | single | 320.25 |
| 103 | 1 | double | 510.30 |
| 104 | 1 | double | 575.40 |
| 201 | 2 | double | 446.25 |
| 202 | 2 | double | 383.25 |
| 203 | 2 | family | 446.25 |
| 301 | 3 | double | 256.20 |
| 302 | 3 | double | 320.25 |
| 303 | 3 | family | 702.45 |
| 401 | 4 | double | 479.85 |
| 402 | 4 | family | 766.50 |
| 403 | 4 | family | 830.55 |
| 501 | 5 | family | 192.15 |
| 502 | 5 | family | 286.65 |
| 503 | 5 | family | 357.00 |
| 601 | 6 | single | 320.25 |
| 602 | 6 | double | 345.45 |
| 603 | 6 | family | 370.65 |
+--------+---------+--------+------------+

mysql> select * from Room where price<500 and type<>'single';


+--------+---------+--------+-------+
| roomno | hotelno | type | price |
+--------+---------+--------+-------+
| 103 | 1 | double | 486 |
| 201 | 2 | double | 425 |
| 202 | 2 | double | 365 |
| 203 | 2 | family | 425 |
| 301 | 3 | double | 244 |
| 302 | 3 | double | 305 |
| 401 | 4 | double | 457 |
| 501 | 5 | family | 183 |
| 502 | 5 | family | 273 |
| 503 | 5 | family | 340 |
| 602 | 6 | double | 329 |
| 603 | 6 | family | 353 |
+--------+---------+--------+-------+

mysql> select * from Booking where dateto is NULL;


+---------+--------+---------+------------+------------+
| hotelno | roomno | guestno | datefrom | dateto |
+---------+--------+---------+------------+------------+
| 1 | 101 | 14003 | 2019-02-12 | 0000-00-00 |
| 2 | 203 | 14001 | 2019-02-10 | 0000-00-00 |
| 4 | 402 | 14007 | 2019-02-01 | 0000-00-00 |
| 5 | 501 | 14006 | 2019-02-04 | 0000-00-00 |
| 6 | 603 | 14010 | 2019-02-06 | 0000-00-00 |
+---------+--------+---------+------------+------------+

mysql> select sum(price) from Hotel H,Room R,Booking B where name='Vivanta_BY_Taj'


and [Link]=[Link] and [Link]=[Link] and [Link]=[Link] and
datefrom<='20190211' and dateto>='20190211';
+------------+
| sum(price) |
+------------+
| 853 |
+------------+

mysql> select sum(price) from Room where roomno not in (select [Link] from Hotel
H,Room R,Booking B where name='ITC_Gardenia' and [Link]=[Link] and
[Link]=[Link] and [Link]=[Link]) and hotelno=2;
+------------+
| sum(price) |
+------------+
| 365 |
+------------+

mysql> select * from Hotel,Room where city='Banglore' and


[Link]=[Link];
+---------+----------------+----------+--------+---------+--------+-------+
| hotelno | name | city | roomno | hotelno | type | price |
+---------+----------------+----------+--------+---------+--------+-------+
| 1 | Vivanta_By_Taj | Banglore | 101 | 1 | single | 244 |
| 1 | Vivanta_By_Taj | Banglore | 102 | 1 | single | 305 |
| 1 | Vivanta_By_Taj | Banglore | 103 | 1 | double | 486 |
| 1 | Vivanta_By_Taj | Banglore | 104 | 1 | double | 548 |
| 5 | HillView | Banglore | 501 | 5 | family | 183 |
| 5 | HillView | Banglore | 502 | 5 | family | 273 |
| 5 | HillView | Banglore | 503 | 5 | family | 340 |
| 6 | KailashIn | Banglore | 601 | 6 | single | 305 |
| 6 | KailashIn | Banglore | 602 | 6 | double | 329 |
| 6 | KailashIn | Banglore | 603 | 6 | family | 353 |
+---------+----------------+----------+--------+---------+--------+-------+

mysql> select roomtype,max(Room_Count) from(select [Link] as roomtype,count(*) as


Room_count from Hotel H,Room R,Booking B where [Link]=[Link] and
[Link]=[Link] and [Link]=[Link] and city='London' group by [Link]) as
Room_details;
+----------+-----------------+
| roomtype | max(Room_Count) |
+----------+-----------------+
| double | 3 |
+----------+-----------------+

You might also like