SELECt g.id, g.name, g.weight, t.total
FROM goods g JOIN (
SELECt goods_id, SUM(count) AS total
FROM trans
GROUP BY goods_id
) t ON g.id = t.goods_id
WHERe t.total > 20 AND g.weight < 50
ORDER BY g.id ASC
SQL93 网易云音乐推荐(网易校招笔试真题)
SELECt DISTINCT m.music_name
FROM follow f JOIN music_likes l ON f.follower_id = l.user_id JOIN music m ON l.music_id = m.id
WHERe f.user_id = '1' AND l.music_id NOT IN (
SELECt music_id
FROM music_likes
WHERe user_id = '1'
)
ORDER BY l.music_id ASC



