sqlwithas排序
發布時間: 2025-03-04 23:30:21
1. sql多條件分組查詢,求sql語句。
分組是用來聚集匯總的,如求平均、求總和、求最大等
你這個不需要分組,直接排序就可以了
selectname,datefromtableorderbynameasc,datedesc
如果每組要按date的降序排列,也挺簡單
with t1 as (select name, max(date) md from table group by name,
t2 as (select table.name name, table.date date, t1.md from table join t1 on table.name=t1.name
order by t1.md)
select name,date from t2
熱點內容