Home > database >  Mysql grouping sorting
Mysql grouping sorting

Time:10-06


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;

CodePudding user response:

reference 1st floor sinat_28984567 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;

Well, don't look for... This is not a data, but this group of maximum minimum...

CodePudding user response:

Refers to a variety of methods in next post

http://blog.csdn.net/acmain_chm/article/details/4126306
[for] take N largest record grouping method of solicitation, and scattered points...

CodePudding user response:

Junction post rate: 0%

When you the solutions of the problems please post.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html

8, how to give points and knot stick?
http://bbs.csdn.net/help#post_dispose

  • Related