Subject RE: [ib-support] Summarization Query Speed Issue
Author Svein Erling Tysvaer
This should be
select p.productID, sum(o.qty)
from product p
left join orderdetail o on (p.productID = o.productID)
left join ordermaster m on (o.ordermasterid = m.ordermasterid and
m.transdate between '2003-01-01' and '2003-02-01')
group by p.productID

or more likely

select p.productID, sum(o.qty)
from product p
left join orderdetail o on (p.productID = o.productID)
join ordermaster m on (o.ordermasterid = m.ordermasterid and
m.transdate between '2003-01-01' and '2003-02-01')
group by p.productID

Don't put columns belonging to a table on the right side of a left join in
the where clause.

Set

At 01:56 04.03.2003 +0700, you wrote:
>CASE 4 : Find Total Sales For Each Product for certain months.
> select p.productID, sum(o.qty)
> from product p
> left join orderdetail o on (p.productID = o.productID)
> left join ordermaster m on (o.ordermasterid = m.ordermasterid)
> where (m.transdate between '2003-01-01' and '2003-02-01')
> group by p.productID
>R