Skip to content

Instantly share code, notes, and snippets.

@radityopw radityopw/cte_b.sql
Last active Feb 29, 2016

What would you like to do?
USE AdventureWorks2012
with the_table as (
SELECT row_number() over(order by orderDate desc, sales.SalesOrderHeader.SalesOrderID desc) as number,Sales.SalesOrderHeader.SalesOrderID, Sales.SalesOrderHeader.OrderDate, Production.Product.ProductNumber, Production.Product.Name,
Sales.SalesOrderDetail.UnitPrice, Sales.SalesOrderDetail.OrderQty, Sales.SalesOrderDetail.UnitPriceDiscount, Sales.SalesOrderDetail.LineTotal
FROM Sales.SalesOrderHeader INNER JOIN
Sales.SalesOrderDetail ON Sales.SalesOrderHeader.SalesOrderID = Sales.SalesOrderDetail.SalesOrderID INNER JOIN
Production.Product ON Sales.SalesOrderDetail.ProductID = Production.Product.ProductID
select * from the_table where number < 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.