Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SELECT col1
, col2
, col1-col2
, max(col1-col2)
FROM captlid
group by col3
col1 col2 col1-col2 max(col1-col2)
4 2 2 2
3 3 0 0
2 4 -2 -2
1 5 -4 -4
okay, i see you do really want MAX, not GREATEST, so i'll leave it to you to look them up in the manualcaptlid said:How's greatest() different from max().
okay, then this is what you want --captlid said:My objective is to find the largest differential between (col1-col2) *0.5 and then subtract (col1-col2) *0.5
SELECT col1
, col2
, ( select max(col1-col2)
from captlid )* 0.5 as m
, (col1-col2) * 0.5 as d
, ( select max(col1-col2)
from captlid )* 0.5
-(col1-col2) * 0.5 as diff
FROM captlid
col1 col2 m d diff
4 2 1.0 1.0 .0
3 3 1.0 .0 1.0
2 4 1.0 -1.0 2.0
1 5 1.0 -2.0 3.0
select max(col1-col2)
from captlid
SELECT col1
, col2
, ( [i]foo[/i] )* 0.5
-(col1-col2) * 0.5 as diff
FROM captlid