From df4fea34373a4b2d07912dbdf1ab51ea0c93c839 Mon Sep 17 00:00:00 2001 From: smallkun Date: Tue, 18 Mar 2025 19:41:55 +0800 Subject: [PATCH] Auto commit --- 2207/MySQL数据库操作综合练习题答案.md | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/2207/MySQL数据库操作综合练习题答案.md b/2207/MySQL数据库操作综合练习题答案.md index 9c222b0..f3306bb 100644 --- a/2207/MySQL数据库操作综合练习题答案.md +++ b/2207/MySQL数据库操作综合练习题答案.md @@ -578,5 +578,50 @@ INSERT INTO travel (tid, time, position, money, aid, count) VALUES (1, '5天', '八达岭', 3000, 101, 10), (2, '7天', '水长城', 5000, 101, 14), (3, '8天', '水长城', 6000, 102, 11); + +#4 +SELECT a.* +FROM travel t, agency a +WHERE t.aid =a.id +GROUP BY a.id +HAVING COUNT(*) = ( + SELECT COUNT(*) + FROM travel t, agency a + WHERE t.aid =a.id + GROUP BY a.id + ORDER BY COUNT(*) DESC + LIMIT 1 +); + +#5 +SELECT t.* +FROM travel t +WHERE t.count = ( + SELECT t.count + FROM travel t + ORDER BY t.count DESC + LIMIT 1 +); + +#6 +SELECT * +FROM travel t +WHERE t.money < 5000; + +#7 +SELECT a.`name` +FROM travel t, agency a +WHERE t.aid =a.id AND t.money = ( + SELECT t.money + FROM travel t, agency a + WHERE t.aid =a.id + ORDER BY t.money DESC + LIMIT 1 +); + +#8 +SELECT SUM(t.time) +FROM travel t, agency a +WHERE t.aid =a.id AND a.`name` = '青年旅行社'; ```