文章目錄
- 14.6.13 列出每個指定設施的預訂總小時數 List the total hours booked per named facility
- 14.6.14 列出每位會員在 2012 年 9 月 1 日之后的首次預訂 List each member’s first booking after September 1st 2012
- 14.6.15 生成成員名稱列表,每行包含成員總數 Produce a list of member names, with each row containing the total member count
- 14.6.16 生成成員編號列表 Produce a numbered list of members
- 14.6.17 再次輸出預訂數量最多的設施 ID, Output the facility id that has the highest number of slots booked, again
- 14.6.18 按使用的(四舍五入)小時數對成員進行排名 Rank members by (rounded) hours used
- 14.6.19 查找前三大創收設施 Find the top three revenue generating facilities
- 14.6.20 按價值分類設施 Classify facilities by value
- 14.7 遞歸 Recursion
- 14.7.1 查找成員 ID 27 的向上推薦鏈 Find the upward recommendation chain for member ID 27
14.6.13 列出每個指定設施的預訂總小時數 List the total hours booked per named facility
列出每個設施預訂的總小時數,記住一個時段持續半小時。輸出表應包含設施 ID、名稱和預訂時間,按設施 ID 排序。
SELECT f.facid, f.name, SUM(b.slots) * .5
FROM facilities AS f
INNER JOIN bookings AS b ON