如图示:请问一下,sql 语句怎么拼写?
如图示:请问一下,sql 语句怎么拼写? 谢谢!
[解决办法]
try this,
select a.MNAME,
max(a.MSTANDARD) 'MSTANDARD',
max(a.MUNIT) 'MUNIT',
max(a.COUNTONE) 'COUNTONE',
max(a.FEEONE) 'FEEONE',
sum(a.COUNTTWO) 'COUNTTWO',
sum(a.FEETWO) 'FEETWO',
max(a.COUNTTHREE) 'COUNTTHREE',
max(a.FEETHREE) 'FEETHREE',
max(a.COUNTONE)+sum(a.COUNTTWO)-max(a.COUNTTHREE) 'COUNTFOUR',
max(a.FEEONE)+sum(a.FEETWO)-max(a.FEETHREE) 'FEEFOUR'
from [表名] a
group by a.MNAME
select
a.MNAME,
max(a.MSTANDARD) "MSTANDARD",
max(a.MUNIT) "MUNIT",
max(a.COUNTONE) "COUNTONE",
max(a.FEEONE) "FEEONE",
SUM(a.COUNTTWO) "COUNTTWO",
SUM(a.FEETWO) "FEETWO",
max(a.COUNTTHREE) "COUNTTHREE",
max(a.FEETHREE) "FEETHREE",
SUM(a.COUNTONE + a.COUNTTWO - a.COUNTTHREE) "COUNTFOUR",
SUM(a.FEEONE + a.FEETWO - a.FEETHREE) "FEEFOUR"
from [表名] a
group by a.MNAME