如何使用select in count in where

时间:2017-03-05 18:36:20

标签: sql

这个陈述的正确语法是什么:

select *
from notices
where count(select * from notices where no_type = 'p'
        or no_type = 'n') > 3

1 个答案:

答案 0 :(得分:0)

这不是编写查询的最佳方式,但如果你真的需要它,这可能会有效

select * from notices as a
where (select count(*) from notices as b where no_type = 'p'
    a.someColumn = b.someColumn) > 3 or (select count(*) from notices as c where
    or no_type = 'n' and a.someColumn = c.someColumn) > 3