Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions week-1/mandatory/2-classes-db/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,50 @@ Below you will find a set of tasks for you to complete to consolidate and extend
To submit this homework write the correct commands for each question here:

```sql
1-
a-SELECT rate from rooms where rate >100;
b-SELECT * from rooms where rate > 100.00;

2-
a-SELECT *, checkout_date - checkin_date as nights from reservations where checkin_date BETWEEN '2020-09-01' and '2020-09-30' and checkout_date- checkin_date >3;
b-select *, checkout_date - checkin_date as night from reservations where (extract(month from checkin_date)) = (extract(month from current_date)) and checkout_date - checkin_date > 3;
3-
SELECT * from customers where city like 'M%';

4- insert into room_types (room_type, def_rate)
values ('PENTHOUSE', '185');

5-
a-INSERT INTO rooms (room_no, rate, room_type) VALUES (501, 185, 'PENTHOUSE');
b-INSERT into rooms (room_no, rate, room_type) VALUES (502, 185, 'PENTHOUSE');

6-INSERT into rooms (room_no, room_type, rate) VALUES(503, 'PREMIER PLUS', 143);

7-
a-SELECT count(room_no) from reservations where checkin_date BETWEEN '2020-08-01' and '2020-08-31';
b-select count(room_no) from reservations where checkin_date >='2020-08-01' and checkout_date <= '2020-08-31';

8-
a-SELECT sum(checkout_date - checkin_date) as nights from reservations where room_no BETWEEN 201 and 299 ;
b-SELECT sum(checkout_date - checkin_date) from reservations where room_no > 201 and room_no < 299 ;

9-
first part of the question:
SELECT * from invoices where total > 300;
second part of the question:
SELECT sum(total) from invoices WHERE total > 300;
third part of the question:
SELECT avg(total) from invoices WHERE total > 300;

10-
first floor = 54:
SELECT sum(checkout_date -checkin_date) as nights from reservations where room_no BETWEEN 101 and 199;
second floor = 63:
SELECT sum(checkout_date -checkin_date) as nights from reservations where room_no BETWEEN 201 and 299;
third floor = 46:
SELECT sum(checkout_date -checkin_date) as nights from reservations where room_no BETWEEN 301 and 399;
forth floor = 40:
SELECT sum(checkout_date -checkin_date) as nights from reservations where room_no BETWEEN 401 and 499;


```
Expand All @@ -32,5 +76,6 @@ Using what you can learn about aggregate functions in the w3schools SQL classes

7. The hotel manager wishes to know how many rooms were occupied any time during the previous month - find that information.
8. Get the total number of nights that customers stayed in rooms on the second floor (rooms 201 - 299).

9. How many invoices are for more than £300.00 and what is their grand total and average amount?
10. Bonus Question: list the number of nights stay for each floor of the hotel (floor no is the hundreds part of room number, e.g. room **3**12 is on floor **3**)
1 change: 1 addition & 0 deletions week-2/mandatory/3-api/cyf-ecommerce-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Loading