Search code examples
flink-sql

use Flink SQL multiple case when


I am using Flink SQL generate explain.

select case when count(*)>1 then '11' end as query,case when src_ip='6' then '22' end as query from table

but found exception,it say

Expression 'src_ip' is not being grouped

when I alter count(*) to others,like event_name...

select case when event_name>'test' then '11' end as query,case when src_ip='6' then '22' end as query from table

It is OK,can you help me?


Solution

  • The query that doesn't work isn't valid SQL. You can't apply an aggregation (such as count(*)) without having a GROUP BY so that the aggregation has something to aggregate over.