当immediate_id与start_id匹配或者immediate_id与end_id匹配时,我想返回任何计数大于3的立即数.start_id将等于end_id并且计数大于3或者start_id将等于immediate_id并且计数大于3.现在返回该特定立即数的所有匹配,而不是立即返回大于3的匹配。 immediate有immediate_id,start有start_id,end有end_id,每个immediate有一个start和start_id有end和end_id。我只想要immediate_id = start_id>的情况3和immediate_id = end_id> 3。
select immediate
count(immediate) OVER (partition by start_id) as matchCount
from addresses where
start_id = end_id
or start_id = immediate_id
and year = 2016
答案 0 :(得分:0)
您需要将or
语句包装在括号中,并实际将> 3
添加到您的where子句中,如下所示:
where count(immediate) > 3 and (immediate_id = start_id or immediate_id = end_id)