There is A table. A, we need to press cell_code, ne_code field group, according to cell_alarm_type drop, cell_alarm_sub_type ascending, take the first data for each group, oralcek can use row_number () over (partiton by cell_code, ne_code order by cell_alarm_type, cell_alarm_sub_type) to do, but the mysql don't know how to get you advice, SQL or stored procedures, data in the table as shown in figure
CodePudding user response:
SELECT cell_code,Ne_code, MAX (cell_alarm_type) AS cell_alarm_type, MIN (cell_alarm_sub_type) AS cell_alarm_sub_type FROM A GROUP BY cell_code, Ne_code;