次のコードがあります
select count(*)
from (select Annotations.user_id
from Annotations, Users
where Users.gender = 'Female'
and Users.user_id = Annotations.user_id
and image_id = 1
group by Annotations.user_id
having sum(case when stem = 'taxi' then 1 else 0 end) > 0 and
sum(case when stem = 'zebra crossing' then 1 else 0 end) > 0
) Annotations
画像 1 の語幹「タクシー」と「横断歩道」を与えた女性の数をカウントします。
サンプルデータ
user id, image id, stem
1 1 image
1 1 taxi
1 1 zebra crossing
2 1 person
2 1 zebra crossing
2 1 taxi
3 1 person
3 1 zebra crossing
期待される結果 (または類似)
stem1, stem2, count
taxi , zebra crossing 2
person, zebra crossing 2
ただし、2000以上のステムがあるため、すべてを特定することはできません。
ステム文字列を指定するのではなく、image_id = 1 および性別 = female でステム行をループする方法を教えてください。
ありがとうございました