jpa - SQL Group by one column and decide which column to choose -


let's have data :

|  id      |    code     |   name   |  number | ----------------------------------------------- |   1      |      20     |        |    10   | |   2      |      20     |   b      |    20   | |   3      |      10     |   c      |    30   | |   4      |      10     |   d      |    80   | 

i group rows code value, real rows (not aggregate function).

i know

 select *   table   group code  

won't work because database don't know row return code same.

so question how tell database select (for example) lower number column in case

|  id      |    code     |   name   |  number | ----------------------------------------------- |   1      |      20     |        |    10   | |   3      |      10     |   c      |    30   | 

p.s.

i know how partition allowed in oracle databases , can't created in jpa criteria builder (what ultimate goal).

why don't use code this?

select          id,         code,         name,         number (     select          *,         row_number() on (partition code order number asc) rowno         table ) s s.rowno = 1 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -