up until now I have always used the where clause for filtering. just for kicks I experimented with a query today
the extended execution plan
query A 50.08%
query B 49.92%
i realize the difference is small, but I'm wondering what is the general practice/guidelines for using Group By vs. Where clause
Jason Meckley
Programmer
Specialty Bakers, Inc.
Code:
--query A.
select b.broker_id, b.broker, sum(c.commission_amount)
from broker b
inner join order_commission_status s on b.broker_id = s.broker_id
inner join order_detail_commission c on b.broker_id = c.broker_id
where (s.status = 1 or s.status = 2)
group by b.broker_id, b.broker
having sum(c.commission_amount) > 0
--query B.
select b.broker_id, b.broker, sum(c.commission_amount)
from broker b
inner join order_commission_status s on b.broker_id = s.broker_id
inner join order_detail_commission c on b.broker_id = c.broker_id
group by b.broker_id, b.broker, s.status
having sum(c.commission_amount) > 0
and (s.status = 1 or s.status = 2)
query A 50.08%
query B 49.92%
i realize the difference is small, but I'm wondering what is the general practice/guidelines for using Group By vs. Where clause
Jason Meckley
Programmer
Specialty Bakers, Inc.