I have a table that has 3 columns
I want to aggregate column 3 by the maximum of absolute values, but display the actual (negative or positive) value.
your help is appreciated
I think this would work. You get de max absolute value of ultimate_load and then change it's sign depending on the sign of MAX(ultimate_load)+MIN(ultimate_load).
SELECT STA,BL, MAX(ABS(ULTIMATE_LOAD)) * case sign(MAX(ULTIMATE_LOAD)+min(ULTIMATE_LOAD)) when 0 then 1 when -1 then -1 else 1 end as maxvalue
FROM TAB
GROUP BY STA, BL
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.