The dataset for these exercises is for a newly created country club, with a set of members, facilities such as tennis courts, and booking history for cd.members cd.bookings cd.facilities Column Name Data Type Column Name Data Type Column Name Data Type memid integer memid integer facid integer surname varchar(200) facid integer name varchar(200) firstname varchar(200) no_of_slots_bookeinteger membercost numeric address varchar(300) starttime timestamp guestcost numeric zipcode integer initialcost numeric telephone varchar(200) monthlymaintenancnumeric recommendedby integer joindate timestamp POINTS TO NOTE Recommendedby is the memid of the person who recommended in cd.bookings, a booking can be made by a guest or by a member. In case of guest, cd.bookings.memid = 0 otherwise it is = memid of cd.members No of hours =( (sum(No of slots) + 10)/20)*10 If booking made by guest then revenue = no_of_Slots_booked * guestcost If booking made by member then revenue = no_of_Slots_booked * membercost Total Revenue of facilities = sum of revenue of all bookings made for that facility Total Revenue on a date = sum of revenue of all bookings made on that date (refer to starttime column) Q1 Create a list of start times for bookings made by member named "Darren Smith" Q2 Create a list of all members who have recommended another member? Ensure that there are no duplicates in the list, and that results are ordered by (surname, firstname). Q3 Create a list of all members who have used a tennis court? Include in your output the name of the court, and the name of the member formatted as a single column. Ensure no duplicate data, and order by the member name followed by the facility name. Q4 Count of the number of facilities that have a cost to guests of 9 or more. Q5 Get the total number of slots booked per facility in the month of September 2012. Produce an output table consisting of facility id and slots, sorted by the number of slots. Q6 List each member's first booking after September 1st 2012 Q7 Output the facility id that has the highest number of slots booked. Ensure that in the event of a tie, all tieing results get output. Q8 Produce a list of members, along with the number of hours they've booked in facilities. Rank them by the number of hours producing output of first name, surname, hours, rank. Sort by rank, surname, and first name. Q9 Produce a list of the top three revenue generating facilities (including ties). Output facility name and rank, sorted by rank and facility name. Q10 For each day in August 2012, calculate a rolling average of total revenue over the previous 15 days. Output should contain date and revenue columns, sorted by the date. Remember to account for the possibility of a day having zero revenue.
santoshyadav121 / club-operation-sql-frame Goto Github PK
View Code? Open in Web Editor NEWThe dataset for these exercises is for a newly created country club, with a set of members, facilities such as tennis courts, and booking history for cd.members cd.bookings cd.facilities Column Name Data Type Column Name Data Type Column Name Data Type memid integer memid integer facid integer surname varchar(200) facid integer name varchar(200) firstname varchar(200) no_of_slots_bookeinteger membercost numeric address varchar(300) starttime timestamp guestcost numeric zipcode integer initialcost numeric telephone varchar(200) monthlymaintenancnumeric recommendedby integer joindate timestamp POINTS TO NOTE Recommendedby is the memid of the person who recommended in cd.bookings, a booking can be made by a guest or by a member. In case of guest, cd.bookings.memid = 0 otherwise it is = memid of cd.members No of hours =( (sum(No of slots) + 10)/20)*10 If booking made by guest then revenue = no_of_Slots_booked * guestcost If booking made by member then revenue = no_of_Slots_booked * membercost Total Revenue of facilities = sum of revenue of all bookings made for that facility Total Revenue on a date = sum of revenue of all bookings made on that date (refer to starttime column)