我有一张看起来像这样的桌子
编号 | 数字 --------------- 1 56721 2 56722 3 43981 4 43982 5 43983 6 43984
我的 MySQL 查询如下所示:
SELECT CASE substr(number,1,2) WHEN '56' then 'class1' WHEN '43' then 'class2' else 'other' END as class,
CASE substr(number,3,2) WHEN '72' then 'subclass1', WHEN '98' then 'subclass2' ELSE 'other' END as subclass, count(id) as ct
FROM table GROUP BY class, subclass HAVING class!='other' AND subclass!='other'
ORDER BY class ASC, subclass DESC;
对应的 PostgreSQL 查询是什么?