![I need to count the U and A corresponding to each layerid. For example,
HYD_NET_LN U 5 A 10
HYD_VAL_PT U 8 A 25
How to write
][1]
PHP中文网2017-05-18 10:55:38
Keep it simple, I don’t know if this is possible.
SELECT layerid,ChangeMold,COUNT(ChangeMold) FROM table_name
GROUP BY layerid,ChangeMold
巴扎黑2017-05-18 10:55:38
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;
巴扎黑2017-05-18 10:55:38
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)
天蓬老师2017-05-18 10:55:38
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