I have two columns in table and I am trying to calculate diff between least performer to every cell in the column.
Column_a column_B
abc 1
DEF 5
GHI 7
JKL 8
I am trying to get an output like below
abc 1 0
def 5 4
ghi 5 6
jkl 8 7
Column_c diff between each cell in column b to min(column b)
Use window functions:
select column_a, column_b, (column_b - min(column_b) over ())
from t;