SQL查询中Select的语法

SQL查询中Select的语法,第1张

SQL查询中Select的语法

这将为您提供A和B胜过C,D和E的所有游戏路线。

select * from games where gameid in        (select gameid from games        where name in ('Anna A', 'Barley B') and winloss=1         group by gameid         having count(*) = 2    intersect     select gameid from games        where name in ('Charly C', 'Dave D', 'Ed E') and winloss = 0         group by gameid         having count(*) = 3) ;

或者,您可以使用:

select *from games where gameid in (    select gameid from games where name = 'Anna A'   and winloss = 1   intersect    select gameid from games where name = 'Barley B' and winloss = 1   intersect     select gameid from games where name = 'Charly C'   and winloss = 0 intersect    select gameid from games where name = 'Dave D' and winloss = 0     intersect    select gameid from games where name = 'Ed E' and winloss = 0    ) ;

最适合您的。

然后

sum
,您可以添加和
group by
以获得累积结果。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5508600.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-13

发表评论

登录后才能评论

评论列表(0条)

保存