mysql group by using the

Problem Description

I now need to look-up table test, which will need to install a field grouping. After grouping there in accordance with the largest field b. Also check out the field c.
I first used the database is mysql8.0

solve

It should be noted:

  • group by group to retain the first time found
  • MYSQL not group by following the 5.7 version will complain in the field with select solution is to use the function any_value (field names)

sql: We just need to follow b fields are sorted first, then in groups. On it.

Guess you like

Origin www.cnblogs.com/zhenghengbin/p/12018748.html