sql - SQLSERVER group by (aggregate column based on other column) -


i have table has 3 columns a, b, c

i want query this:

select a, max(b), ( c in row having max b ) table group a. 

is there way such query?

test data:

a    b    c 2    5    3 2    6    1 4    5    1 4    7    9 6    5    0 

the expected result be:

2    6    1 4    7    9 6    5    0 

;with cte (     select  a,             b,             c,             rn = row_number() over(partition order b desc)     yourtable ) select a, b, c cte rn = 1 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -