Created
June 28, 2012 17:26
-
-
Save ksummerlin/3012676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--@max_other_orders is a parameter to stored proc | |
select top (@max_other_orders) | |
OH.SalesOrderID, | |
OH.CustomerId, | |
OH.SalesOrderNumber, | |
OH.Status, | |
count(*) over(partition by OH.CustomerId) as OtherOrdersCount | |
from Sales.SalesOrderHeader OH | |
where | |
OH.CustomerID = @customer_id | |
and OH.SalesOrderID <> @current_sales_id | |
order by OH.OrderDate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment