【发布时间】:2017-05-10 10:02:06
【问题描述】:
我的 mysql 查询需要一些帮助。我有一张看起来像的桌子:
然后我想用这个查询进行选择:
select id, class, defaut, input, round(input - defaut) test from table1
group by class, id with rollup
我想要这样的输出:
但是我的查询给了我这样的结果:
请帮忙,谢谢
【问题讨论】:
-
我认为你可以用更少的行和/或 sqlfiddle/rextest 来说明问题。
-
您选择 id、class、defaut 和 input,但仅按其中两列分组。虽然存在功能依赖,但对于 ROLLUP 而言,这并不完全合理。