MAX(value) with TWO COLUMN

Viewed 66

I have this value for exemple

 VAL1 VAL2
    04   ZZ
    06   TT
    05   XX
    03   XX
    04   ZZ
    09   TT

I want query that show me the max (last record) of each value of column val2

For exemple , for TT = 09 , XX = 03 , ZZ = 04 .

Can you please provide ? with HANA query if possible ?

1 Answers

I don't know hana but SQL looks like this

select val2, max(val1) as maxVal
from myTable
group by val2

FROM SAP - "The generated SQL ANSI code is compliant and should work on most databases which are not yet supported by the application."

The code ^^ I provided above is pretty much ANSI SQL, which should work in most SQL databases.

More from SAP [ANSI SUPPORT] - "E051-02 -- GROUP BY clause -- Full Support.....E091-03 -- MAX -- Full Support"

Related