2017-03-05 21 views
-2

究竟是什麼statment正確的語法選擇計數:如何使用在

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

你的目標究竟是什麼?那個查詢沒有什麼意義 – GurV

+0

什麼語法? –

+0

也許你打算在子查詢中從no_type ='p'或no_type ='n''的通知中選擇count(*)。 – GurV

回答

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