我正在尝试列出每支球队在总比赛中输掉的比赛比例。
我尝试了以下方法,但似乎不起作用:
select teams.name as Name,
Lost
from teams
join matches on teams.name in (matches.home, matches.away)
group by teams.name
having (1 - (matches.winner / (count (matches.home) + count (matches.away)))) as Lost;
我在最后一行编写函数的方式有问题吗?
关系图供参考: