如何创建函数过滤器 PostgreSQL 到 MySQL?

How create function filter PostgreSQL to MySQL?

PostgreSQL 如何创建函数 filter 到 MySQL?

I tried as follows, but failed:

select
    CASE WHEN statusstorie = false and statusTwentyFive = true and category not in ('goals') and space = 'personal' THEN count(*) ELSE 0 END as "25%",
    CASE WHEN statusstorie = false and statusFifty = true and category not in ('goals') and space = 'personal' THEN count(*) ELSE 0 END as "50%",
    CASE WHEN statusstorie = false and statusSeventyFive = true and category not in ('goals') and space = 'personal' THEN count(*) ELSE 0 END as "75%",
    CASE WHEN statusstorie = false and statusOneHundred = true and category not in ('goals') and space = 'personal' THEN count(*) ELSE 0 END as "100%"
from goals 

PSQL Example:

select
    count(*) filter(where statusstorie = false and statusTwentyFive = true and category not in ('goals') and space = 'personal')  "25%",
    count(*) filter(where statusstorie = false and statusFifty = true and category not in ('goals') and space = 'personal') "50%",
    count(*) filter(where statusstorie = false and statusSeventyFive = true and category not in ('goals') and space = 'personal') "75%",
    count(*) filter(where statusstorie = false and statusOneHundred = true and category not in ('goals') and space = 'personal') "100%"
from goals 

注意:如果可能的话我想将函数复制到MySQL

CREATE FUNCTION filter()

这对你有用吗?

select
    sum(CASE WHEN statusstorie = false and statusTwentyFive = true and category not in ('goals') and space = 'personal' THEN 1 ELSE 0 END) as "25%",
    sum(CASE WHEN statusstorie = false and statusFifty = true and category not in ('goals') and space = 'personal' THEN 1 ELSE 0 END) as "50%",
    sum(CASE WHEN statusstorie = false and statusSeventyFive = true and category not in ('goals') and space = 'personal' THEN 1 ELSE 0 END) as "75%",
    sum(CASE WHEN statusstorie = false and statusOneHundred = true and category not in ('goals') and space = 'personal' THEN 1 ELSE 0 END) as "100%"
from goals