|
SELECT md,(select sum (tt.xs) from tt where yf= 1 and md = "aa") as 1y,(select sum (tt.xs) from tt where yf= 2 and md = "aa") as 2y,(select sum (tt.xs) from tt where yf= 3 and md = "aa") as 3y
FROM tt
where md = "aa"
GROUP BY tt.md
UNION ALL
SELECT md,(select sum (tt.xs) from tt where yf= 1 and md = "bb") as 1y,(select sum (tt.xs) from tt where yf= 2 and md = "bb") as 2y,(select sum (tt.xs) from tt where yf= 3 and md = "bb") as 3y
FROM tt
where md = "bb"
GROUP BY tt.md
UNION ALL SELECT md,(select sum (tt.xs) from tt where yf= 1 and md = "cc") as 1y,(select sum (tt.xs) from tt where yf= 2 and md = "cc") as 2y,(select sum (tt.xs) from tt where yf= 3 and md = "cc") as 3y
FROM tt
where md = "cc"
GROUP BY tt.md;
麻烦那位大虾帮忙简化下以上这段东东 |
|