newmediaguy
Programmer
Hi Guys
I have the following SQL statment in SQL Server 2k that I use in an ASP page.
--------------------------------------
SELECT DISTINCT
OrderBody.OrderID AS Expr1, OrderBody.Quantity AS qty, OrderBody.ProductID AS product, OrderBody.CustomerEmail, OrderBody.SellPrice, OrderBody.BuyPrice, OrderBody.Returned, OrderBody.Supplier, OrderBody.SellPrice * OrderBody.Quantity AS Cost, OrderHeaders.DateStamp
FROM user_tbl INNER JOIN OrderBody ON user_tbl.EmailAddress = OrderBody.CustomerEmail INNER JOIN OrderHeaders ON OrderBody.OrderID = OrderHeaders.OrderID
WHERE (user_tbl.EmailAddress'chrisd@hotmail.co.uk')
GROUP BY OrderBody.OrderID, OrderBody.Quantity, OrderBody.ProductID, OrderBody.CustomerEmail, OrderBody.SellPrice, OrderBody.BuyPrice,OrderBody.Returned, OrderBody.Supplier, OrderHeaders.DateStamp
----------------------------------
Sorry its a bit long.
What it is supose to do is grab all of a given users order id's then the products and the total the total amount of products per order and there cost.
for example
-------------------------------
Orderid qty cost
111111 2 20
222222 4 60
-------------------------------
however when i get to an order with more than one product i get this back
-------------------------------
Orderid qty cost
111111 2 20
222222 4 60
222222 2 62
-------------------------------
But i just want distinct (orderid) order total for all products
Any thoughts would be appreciated, sorry it's so big, i can email a stripped down version if you would like.
Many thanks
Glen
glen@b-n-m.com
I have the following SQL statment in SQL Server 2k that I use in an ASP page.
--------------------------------------
SELECT DISTINCT
OrderBody.OrderID AS Expr1, OrderBody.Quantity AS qty, OrderBody.ProductID AS product, OrderBody.CustomerEmail, OrderBody.SellPrice, OrderBody.BuyPrice, OrderBody.Returned, OrderBody.Supplier, OrderBody.SellPrice * OrderBody.Quantity AS Cost, OrderHeaders.DateStamp
FROM user_tbl INNER JOIN OrderBody ON user_tbl.EmailAddress = OrderBody.CustomerEmail INNER JOIN OrderHeaders ON OrderBody.OrderID = OrderHeaders.OrderID
WHERE (user_tbl.EmailAddress'chrisd@hotmail.co.uk')
GROUP BY OrderBody.OrderID, OrderBody.Quantity, OrderBody.ProductID, OrderBody.CustomerEmail, OrderBody.SellPrice, OrderBody.BuyPrice,OrderBody.Returned, OrderBody.Supplier, OrderHeaders.DateStamp
----------------------------------
Sorry its a bit long.
What it is supose to do is grab all of a given users order id's then the products and the total the total amount of products per order and there cost.
for example
-------------------------------
Orderid qty cost
111111 2 20
222222 4 60
-------------------------------
however when i get to an order with more than one product i get this back
-------------------------------
Orderid qty cost
111111 2 20
222222 4 60
222222 2 62
-------------------------------
But i just want distinct (orderid) order total for all products
Any thoughts would be appreciated, sorry it's so big, i can email a stripped down version if you would like.
Many thanks
Glen
glen@b-n-m.com