# 没有使用group by也可以使用sum函数,因为默认是所有数据行自成一组SELECTSUM(b.apple_count+IFNULL(c.apple_count,0)) apple_count,SUM(b.orange_count+IFNULL(c.orange_count,0)) orange_count
FROM Boxes b
LEFTJOIN Chests c
ON b.chest_id=c.chest_id
1.3 运行截图
2 应该被禁止的Leetflex账户
2.1 题目内容
2.1.1 基本题目信息
2.1.2 示例输入输出
2.2 示例sql语句
# 可能包含重复项,意味着需要考虑去重的事情SELECTdistinct L1.account_id
FROM LogInfo L1
INNERJOIN LogInfo L2
ON L1.account_id=L2.account_id AND L1.ip_address <> L2.ip_address
AND L1.login between L2.login AND L2.logout
2.3 运行截图
3 大满贯数量
3.1 题目内容
3.1.1 基本题目信息1
3.1.2 基本题目信息2
3.1.3 示例输入输出
3.2 示例sql语句
# 需要使用UNION ALL 因为不需要去重# 没有结果不包含在结果集中,就使用INNER JOINSELECT p.player_id,p.player_name,t1.n2 grand_slams_count
FROM Players p
INNERJOIN(SELECT n1,count(*) n2
FROM(SELECT Wimbledon n1
FROM Championships
UNIONALLSELECT Fr_open n1
FROM Championships
UNIONALLSELECT US_open n1
FROM Championships
UNIONALLSELECT Au_open n1
FROM Championships
)t
GROUPBY t.n1
)t1
ON p.player_id=t1.n1