MySQL max value from subquery and group by problem?

I'm don't think you want or need the subquery. What does this return for you? SELECT products.Id, products.

Name, MAX(discounts. Amount) AS discount FROM products LEFT JOIN coupons ON products.Id = coupons. Product_id LEFT JOIN discounts ON coupons.

Id = discounts. Coupon_id GROUP BY products.id.

Unfortunately it's not as easy as this. I would have use joins but there are actually four subqueries - each checking for a different type of possible discount. It didn't seem possible for me to structure the joins in a way that wouldn't require each product to have all four joins.

The subqueries make that condition easier/possible. I guess I'll play with those more. – BotskoNet Jan 10 at 20:14.

You group by productid only, while the subselect actually return three values (one for each coupon of the product). I would actually expect this query to return an error. You should either move the discount one level up, or move the coupons to the subselect.An example of the first (subqueries are typically slower in MySQL): select p.

Productid, max(d. Discount) as discount from product p left join coupon c on c. Productid = p.

Productid left join discount d on d. Couponid = c. Couponid group by p.productid.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions