MYSQL choosing value used of column with different values when Grouping -


sample mysql table:

carnum,cartype,carname 1,sportscar,mustang 2,sportscar,mustang gt 3,sportscar,mustang gt 

when run query:

select carname, cartype cars group cartype 

i get:

mustang,sportscar 

what want is:

mustang gt,sportscar 

is there way make group use recent carname (mustang gt) rather first 1 (mustang)? tried sorting in various ways had no luck.

thanks much.

try 1

select carname, cartype cars  carnum in( select max(carnum) cars group cartype );  

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -