表结构
name jishi jifang
a 2 1
a 2 1
a 3 2
a 3 2要求完成这样的查询:
总机时:所有jishi相加,各机房(jifang)的机时name total jishi1 jishi2
a 10 4 6
name jishi jifang
a 2 1
a 2 1
a 3 2
a 3 2要求完成这样的查询:
总机时:所有jishi相加,各机房(jifang)的机时name total jishi1 jishi2
a 10 4 6
(select sum(jishi) from table_name where jishi = 2) jishi1 ,
(select sum(jishi) from table_name where jishi = 3) jishi2
from table_name
group by name