
以第一列分組,如果行數少于3,第四列中全部小于3則回傳1;如果行數大于3,第四列中至少三行小于3,就回傳1.
uj5u.com熱心網友回復:
select col2,count(1) ,max(col4) ,count(case when col4<3 then 1 else 0 end )case when count(1) < 3 and max(col4)<3
then 1
when count(1)> 3 and count(case when col4 <3 then 1 else 0 end ) >=3
then 1
end
from table
group by col1
uj5u.com熱心網友回復:
select a,
case when (count(a)<=3 and count(m)=count(a)) or (count(a)>3 and count(m)>=3) then 1 else 0 end
from (select C_DEPART_ID AS A,case when sign(MARKET_RANKING-3)=1 then null else 1 end as m
from test_T)
group by C_DEPART_ID
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/14665.html
標籤:基礎和管理
下一篇:批量將b表的查詢結果user_name一一對應更新到a表對應的name欄位,a表的id欄位和b表的id_number欄位內容相同
