enrique_aeo
asked on
the client, the product you buy code more times (max sod.OrderQty)
Hi experts
i have this query
SELECT [CustomerID], sod.ProductID, sod.OrderQty
FROM [Sales].[SalesOrderHeader] soh
join [Sales].[SalesOrderDetail] sod
on soh.[SalesOrderID] = sod.[SalesOrderID]
where [CustomerID] = 29921
order by [CustomerID], sod.ProductID, sod.OrderQty desc
this is the results
CustomerID ProductID OrderQty
29921 707 4
29921 707 3
29921 707 2
29921 708 3
29921 708 1
29921 711 3
29921 711 3
29921 711 1
29921 712 3
29921 712 3
29921 712 2
29921 712 1
i need this results
CustomerID ProductID OrderQty
29921 707 4
29921 708 3
29921 711 3
29921 712 3
a customer can buy several products, the products may be the same, I need the client, the product you buy code more times (max sod.OrderQty)
i have this query
SELECT [CustomerID], sod.ProductID, sod.OrderQty
FROM [Sales].[SalesOrderHeader]
join [Sales].[SalesOrderDetail]
on soh.[SalesOrderID] = sod.[SalesOrderID]
where [CustomerID] = 29921
order by [CustomerID], sod.ProductID, sod.OrderQty desc
this is the results
CustomerID ProductID OrderQty
29921 707 4
29921 707 3
29921 707 2
29921 708 3
29921 708 1
29921 711 3
29921 711 3
29921 711 1
29921 712 3
29921 712 3
29921 712 2
29921 712 1
i need this results
CustomerID ProductID OrderQty
29921 707 4
29921 708 3
29921 711 3
29921 712 3
a customer can buy several products, the products may be the same, I need the client, the product you buy code more times (max sod.OrderQty)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.