The question here is similar:
SQL Selecting multiple columns based on max value in one column
but in that question, it suggests sql. I want to do in java side.
In java spring boot, i wrote this:
 Qmk104 findFirstBypakAndpolOrderBytecDesczeyDesc(String pak, int pol)
so with that, i can return the row with max tec which has max zey also.
After that, i will get tec and zey:
int maxtec;
int maxzey;
and with those, i will make a query again to get the data with max tec which has max zey.
tec zey  pak 
0   1     24
1   2    24
2   0    25
2   1    25
4   5    26
5   0    27
5   1    28
5   2     2(this is max tec with zey. max tec= 5. tec 5 has max 1 zey)
5   2     4(but i need also this because max tec with zey so i will make another query to get  both)
in sql, i can get easy
select * from qmk104 f where POL=390097 and PAK='K'and
        (TEC) in
        (select max(t.TEC) from qmk104 t
         where t.POL=f.POL and t.PAK=f.PAK)
                                and ZEY in (
        select max(t.ZEY) from qmk104 t
        where t.POL=f.POL and t.PAK=f.PAK and t.TEC = f.TEC
    );
how can get it in spring data? With criteria?
 
    