标签:bubuko ice 代码 over png 数据 sql语句 image 技术分享
有两个数据表City表和Price表,CIty表的结构如下:
Price表的结构如下:
查询每个城市最大的销售价格,并以最大价格进行降序排列,SQL语句的代码如下:
select top 5 * from (select ROW_NUMBER() over(order by TmpTable.AdultyPrice desc) NID, City.*, TmpTable.AdultyPrice from City,(select MAX(Price.AdultyPrice) as AdultyPrice,PID from City inner join Price on City.LID = Price.PID group by Price.PID) as TmpTable where LID = PID) as tmp where tmp.NID between 1 and 5
运行结果:
标签:bubuko ice 代码 over png 数据 sql语句 image 技术分享
原文地址:https://www.cnblogs.com/feiyuhuo/p/9069542.html