在SQL中,如何统计满足某些条件且出现次数大于等于某次数的行

2025-04-08 20:33:55
推荐回答(2个)
回答1:

select a.*

  from renkou a, (select xb, dz, nl

           from renkou

          where xb = '男' and dz not in ('温州', '成都')

          group by xb, dz, nl

         having count(1) >= 3) b

 where a.xb = b.xb and a.dz = b.dz and a.nl = b.nl


是这样吗?

回答2:

题主参考如下语句:
select 列 from 表 where xb='男' and DZ not in ('温州','成都') and NL>=3

祝好运 望采纳。