Home > database >  Mysql, bosses help look at this statement how to write
Mysql, bosses help look at this statement how to write

Time:10-08

SQL="SELECT the Title, id, the Summary, Photo, the parent, the Content, type, SUBSTRING_INDEX (GROUP_CONCAT (pv ORDER BY pv desc), ', ', 1) PVS FROM" + tableName2 + "GROUP BY the parent";
Requirements are in accordance with the pv field tableName2 descending order then pv maximum group detected in each group of the records, the situation is executed according to the parent ascending order, how to deal with this

CodePudding user response:

The select t3. * from t3, t (
The select t2. The parent, t2. Pv from (
Select t1. * from t t1 order by t1. The pv desc
) t2 group by t2. The parent
T4)
Where t3. The parent=t4. Parent and t3. The pv=t4. Pv