MySQL Forums
Forum List  »  Newbie

sum, group by, union
Posted by: vanessa vercruysse
Date: April 06, 2005 12:47AM

Hi everyone,

I have a problem with a query but I don't know if what I want will be possible. These are my tables:
TblProduct(Number, Name)
TblProductDelivery(NumberDelivery, Date, ProductNumber, Count)
TblProductSell(NumberSell, Date, ProductNumber, Count).
Now what i want to do is make a query that has all the products. Then the products that have a delivery must have the sum(Count), others must have 0. Then for the products that have a sell I want the Same. Example

Product Delivery Sell
Computer 20 5
Radio 0 0
Tv 5 0

Now i don't know if it's possible. I've tried several things but the result is never ok. For example the ones that don't have a delivery or sell they get the sum of the total delivery's.
Like in the example I get for the Radio delivery 25. Then also when a product has multiple deliveries he makes the sum and then multiplies it with the number of deliveries.

Hope someone can help

Vanessa

Options: ReplyQuote


Subject
Written By
Posted
sum, group by, union
April 06, 2005 12:47AM
April 06, 2005 11:02AM
April 07, 2005 05:45AM
April 07, 2005 10:25AM
April 07, 2005 01:34PM
April 07, 2005 03:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.