一个table, x, y, z 3个字段, 求y-z的最大值所对应的x值,自己写了query,不过有错误select temp.a
from
(select x a,abs(y-z) b
from table t
where z in
(SELECT z FROM `t` WHERE z > 0)
group by x) temp
where temp.b in (select max(b) from temp)提示 table.temp 不存在本人初学,还望高手们多多指点
from
(select x a,abs(y-z) b
from table t
where z in
(SELECT z FROM `t` WHERE z > 0)
group by x) temp
where temp.b in (select max(b) from temp)提示 table.temp 不存在本人初学,还望高手们多多指点
from
(select x a,abs(y-z) b
from table t
where z in
(SELECT z FROM `t` WHERE z > 0)
group by x) temp
where temp.b in (select max(b) from (select x a,abs(y-z) b
from table t
where z in
(SELECT z FROM `t` WHERE z > 0)
group by x) temp1)
派生表是不是只能用在from里啊?有更简洁的query吗?