SELECT
layerid,
sum(case when changeMold='U' then 1 else 0 end) changeMold_U,
sum(case when changeMold='A' then 1 else 0 end) changeMold_A
FROM table_name
GROUP BY layerid;
select layerid,changeMold,count(*) as num from TABLE where layerid in (select layerid from TABLE group by layerid) group by changeMold; The performance of this SQL is very poor
Keep it simple, I don’t know if this is possible.
SELECT layerid,ChangeMold,COUNT(ChangeMold) FROM table_name
GROUP BY layerid,ChangeMold
select count(*),layid,changeMold from tbl group by layid,changeMold
If you want to count such large files. It is better to check them all and then process the array more conveniently (sql is relatively weak)
select layerid,changeMold,count(*) as num from TABLE where layerid in (select layerid from TABLE group by layerid) group by changeMold; The performance of this SQL is very poor