1

如何为制片人、作家、作家选择具有相同角色值的标题数量?

Take看起来像这样,

title | year | person | role(actor, director, producer or writer)

推理应该沿着这条线,

SELECT COUNT(title) 
FROM movie_table 
WHERE role(writer,director, producer)= same person
4

2 回答 2

0

尝试

SELECT COUNT(title) 
from movie_table
WHERE role in ('producer', 'writer')
and movie_person is not null
group by title
having count(distinct role) = 2
and count(distinct movie_person) = 1
于 2012-10-23T16:02:27.563 回答
0

使用带有可选连接条件的自连接(不在同一行):

SELECT COUNT(t1.title)
FROM movie_table t1
JOIN movie_table t2 ON t1.id != t2.id 
    AND (t1.writer = t2.writer
      OR t1.director = t2.director
      OR t1.producer = t2.producer)
于 2013-01-03T00:57:19.607 回答