【发布时间】:2013-03-05 20:37:18
【问题描述】:
我有以下:
SELECT nominees.personname, awards.name as awards, nominees.filmname
FROM nominees, awards WHERE nominees.aid = awards.aid and nominees.personname is not
NULL GROUP BY nominees.personname, awards.name, nominees.filmname
ORDER BY nominees.personname;
这会产生下表:
"personname" "awards" "filmname"
"Ang Lee" "director" "Life of Pi"
"Anglelina J." "actress" "The Tourist"
"Ann Dowd" "supporting actress" "Compliance"
"Anne Hathaway" "actress" "Love and Other Drugs"
"Anne Hathaway" "supporting actress" "Les Misrables"
"Annette Bening" "actress" "The Kids Are All Right"
"Another Year" "screenplay" "Mike Leigh"
"A.R. Rahman" "score" "127 Hours"
"AR Rahman" "score" "127 Hours"
"Barbara Hershey" "supporting actress" "Black Swan"
"Ben Affleck" "actor" "Argo"
"Ben Affleck" "director" "Argo"
我正在尝试获取仅包含因同一部电影获得两个单独奖项提名的人的集合。在这张只有“Ben Affleck”的特殊表格中。
结果应该是
"personname" "awards" "filmname"
"Ben Affleck" "actor" "Argo"
"Ben Affleck" "director" "Argo"
但我似乎无法理解,我尝试使用 HAVING 和某种计数方法,但无法使其正常工作。任何帮助表示赞赏。
【问题讨论】:
-
你能提供更多关于提名和奖项的表格结构的信息吗?
标签: sql postgresql count