数据:
我需要2个查询来选择
请给我一些解决这个任务的提示! 我限制不使用shape_forms的“group by”但是如果没有合适的解决方案
答案 0 :(得分:1)
1
select s.shape_id
from shapes s
inner join shape_forms sf on sf.shape_id = s.shape_id
group by s.shape_id
having
(
sum(shape_form = 1) = 0
and sum(shape_form in (0,2)) >= 2
)
or sum(shape_form <> 0) = 0
2
select s.shape_id
from shapes s
inner join shape_forms sf on sf.shape_id = s.shape_id
group by s.shape_id
having sum(shape_form <> 2) = 0