SQL 练习记录
Posted 拍空格
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL 练习记录相关的知识,希望对你有一定的参考价值。
--1. 统计订单金额累计>=10000的用户 最近的5笔交易记录
select * from (
select t1.ID, t1.[Money], t1.InitialTime, t1.[User], u1.Name,u1.Mobile, row_number() over(partition by t1.[User] order by t1.InitialTime desc) as num
from [TradeFictitious] t1
join
(
select [User] from TradeFictitious
group by [User]
having sum(Money)>=100000
) as j1
on t1.[User] = j1.[User]
left join [User] u1
on t1.[User] = u1.ID)T
where num<=5
go
以上是关于SQL 练习记录的主要内容,如果未能解决你的问题,请参考以下文章