标签:des style blog color 数据 ar div line
Northwind数据库,选取价格第二高的产品。
有两种方法,一个是用Row_Number()函数:
SELECT productname FROM (SELECT TOP 2 productname, Row_Number() OVER (ORDER BY unitprice desc) AS rownum FROM Products) AS tbl WHERE rownum = 2;
另一种是对子语句的的结果再进行排序:
SELECT top 1 productname FROM (SELECT TOP 2 productname,unitprice FROM Products order by unitprice desc) AS tbl order by tbl.unitprice asc
SQL学习笔记:选取第N条记录,布布扣,bubuko.com
标签:des style blog color 数据 ar div line
原文地址:http://www.cnblogs.com/nixjojo/p/3900109.html