List:General Discussion« Previous MessageNext Message »
From: mysql Date:October 12 2007 9:31pm
Subject:Re: LEFT JOIN (SELECT ...) -- no joy
View as plain text  
Andrew Carlson wrote:
> Is there a purchase order (10002) with no orders in the order_details table?

No, PO 10002 is related to the order_id = 2 here:

>>mysql> SELECT order_id, SUM(quantity * unit_price) AS subtotal
>>    -> FROM order_details GROUP BY order_id;
>>
>>+----------+----------+
>>| order_id | subtotal |
>>+----------+----------+
>>|        1 |   101.94 |
>>|        2 |    47.97 |
>>+----------+----------+

But i'm getting NULL for subtotal on all of them, anyway.

The same query works as exactly as expected in Postgres with some table 
modifications to allow for the different datatypes. The outer query 
should have no problem grabbing the correct subtotal from the joined query.

b
Thread
LEFT JOIN (SELECT ...) -- no joymysql12 Oct
Re: LEFT JOIN (SELECT ...) -- no joymysql12 Oct