SELECT t.pid,
t.txt,
t.price,
t.qty - IFNULL(qs.qty_sold, 0) 'onhand_qty'
FROM PRODUCTS t
LEFT JOIN (SELECT o.pid,
SUM(o.qty) 'qty_sold'
FROM ORDERS o) qs ON qs.pid = t.pid
WHERE t.pid = ?
i have trouble running this statemen
009/9/15 Gert Cuykens :
> SELECT t.pid,
> t.txt,
> t.price,
> t.qty - IFNULL(qs.qty_sold, 0) 'onhand_qty'
> FROM PRODUCTS t
> LEFT JOIN (SELECT o.pid,
> SUM(o.qty) 'qty_sold'
> FROM ORDERS o) qs ON qs.pid = t.pid
> WHERE t.pid = ?
>
>
Gert Cuykens
wrote:
> SELECT t.pid,
> t.txt,
> t.price,
> t.qty - IFNULL(qs.qty_sold, 0) 'onhand_qty'
> FROM PRODUCTS t
> LEFT JOIN (SELECT o.pid,
> SUM(o.qty) 'qty_sold'
> FROM ORDERS o) qs ON qs.pid = t.pid
>WHERE t.pid = ?
>
> i
On Wed, Sep 16, 2009 at 1:35 AM, Igor Tandetnik wrote:
> Gert Cuykens
> wrote:
>> SELECT t.pid,
>> t.txt,
>> t.price,
>> t.qty - IFNULL(qs.qty_sold, 0) 'onhand_qty'
>> FROM PRODUCTS t
>> LEFT JOIN (SELECT o.pid,
>> SUM(o.qty) 'qty_sold'
>>
Gert Cuykens
wrote:
> On Wed, Sep 16, 2009 at 1:35 AM, Igor Tandetnik
> wrote:
>> Perhaps your query could be a bit clearer when written this way:
>>
>> select t.pid, t.txt, t.price, t.qty - IFNULL(sum(o.qty), 0)
>> onhand_qty from PRODUCTS t left join ORDERS o on t.pid = o.pid
>
> This does not
On Wed, Sep 16, 2009 at 8:26 PM, Igor Tandetnik wrote:
> Gert Cuykens
> wrote:
>> On Wed, Sep 16, 2009 at 1:35 AM, Igor Tandetnik
>> wrote:
>
>>> Perhaps your query could be a bit clearer when written this way:
>>>
>>> select t.pid, t.txt, t.price, t.qty - IFNULL(sum(o.qty), 0)
>>> onhand_qty fr
Gert Cuykens
wrote:
> On Wed, Sep 16, 2009 at 8:26 PM, Igor Tandetnik
> wrote:
>> Gert Cuykens
>> wrote:
>>> On Wed, Sep 16, 2009 at 1:35 AM, Igor Tandetnik
>>> wrote:
>>
Perhaps your query could be a bit clearer when written this way:
select t.pid, t.txt, t.price, t.qty - IFNULL
On Wed, Sep 16, 2009 at 9:50 PM, Igor Tandetnik wrote:
> Gert Cuykens
> wrote:
>> On Wed, Sep 16, 2009 at 8:26 PM, Igor Tandetnik
>> wrote:
>>> Gert Cuykens
>>> wrote:
On Wed, Sep 16, 2009 at 1:35 AM, Igor Tandetnik
wrote:
>>>
> Perhaps your query could be a bit clearer when writ
Gert Cuykens
wrote:
> select t.pid, t.txt, t.price, t.qty - IFNULL(sum(o.qty), 0) onhand_qty
> from PRODUCTS t left join ORDERS o on t.pid = o.pid group by t.pid
>
> Works also thanks.
> So you do not believe the following has a performance penalty ?
>
> SELECT pid, txt, price, qty-coalesce((SELEC
9 matches
Mail list logo