In the first column group, if the number of lines is less than 3, the fourth column in less than 3 returns all 1; If the number of lines is more than 3, the fourth column of at least three lines is less than 3, it returns 1.
CodePudding user response:
The select col2, count (1), Max (col4), count (case when col4 & lt; 3 then 1 else 0 end)The case when the count (1) & lt; 3 and Max (col4) & lt; 3
Then 1
When the count (1) & gt; 3 and the count (case when col4 & lt; 3 then 1 else 0 end) & gt;=3
Then 1
End
From the table
Group by col1
CodePudding user response:
select a,
Case when the count (a) & lt; (m)==3 and count count (a)) or (count (a) & gt; 3 and the count (m) & gt; Then one else 0=3) end
The from (select C_DEPART_ID AS A case when sign (MARKET_RANKING - 3)=1 then null else end AS 1 m
The from test_T)
Group by C_DEPART_ID