mysql - sql query statistics
PHPz
PHPz 2017-05-18 10:53:38
0
5
903

![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]

PHPz
PHPz

学习是最好的投资!

reply all(5)
Ty80

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

巴扎黑
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;
巴扎黑

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)

Peter_Zhu

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template