【发布时间】:2020-08-03 08:58:51
【问题描述】:
每年报告当年只有女性演员的电影的百分比,以及当年制作的电影总数。例如,一个答案是:1990 31.81 13522 表示 1990 年有 13,522 部电影,其中 31.81% 只有女性演员。你不需要四舍五入你的答案。
以下代码
select a.year, a.c*100.00/b.c as percentage, b.c as total_overall
from (select z.year, count(*) as c
from movie z
where not exists (select *
from person x,M_cast xy
where x.pid = xy.pid and xy.mid = z.mid and x.Gender!='Female')
group by z.year) a,
(select z.year, count(*) as c from movie z group by z.year) b
where a.year=b.year
order by a.year;
以下代码不起作用
select z.year, count(*)
from movie z
where not exists (select *
from actor x, casts xy
where x.id = xy.pid and xy.mid = z.id and x.gender!='F')
group by z.year;
指导我如何选择只有女性演员的电影
如何为上述语句编写sql查询
【问题讨论】:
标签: python mysql sql count average