mysql如何使用分组排序

时间:2022-12-06 01:19

mysql如何使用分组排序

mysql中使用分组排序的方法

在mysql中使用order by方法实现分组排序

实现方法如下:

select id, (@rowno := @rowno + 1) as rank,

score,

(C.end_time - C.start_time) as timeConsuming,

start_time,

real_name,

tel,

expiry_code

from (SELECT *

FROM (select *

from t_q_order B

where B.score > 0

and B.tel IS NOT NULL

order by B.score desc,

(B.end_time - B.start_time) asc,

B.start_time asc) as A

group by A.tel

ORDER BY A.score desc,

(A.end_time - A.start_time) asc,

A.start_time asc)

as C,

(select @rowno := 0) t

where (C.end_time - C.start_time) > 5 limit 0,50;

标签:
随便看看
本类推荐
本类排行
热门标签

我国国家通讯社行不行啊细狗新年贺词祝福语2023年祝福语新年新年贺词新年贺词祝福语居家抗病毒小药箱除夕高速免费吗2022年除夕高速免费吗春联春联句子大全春联句子大全七字年夜饭十二道菜年夜饭十二道菜单年夜饭吃什么年夜饭吃什么菜吃年夜饭的寓意年夜饭黑芝麻菊花茶晒菊花茶腌腊肉送妈妈生日礼物汉白玉送闺蜜水钻送女人礼物爸爸生日送礼物送老公