how about this:

來源: 2011-01-09 22:03:27 [舊帖] [給我悄悄話] 本文已被閱讀:

select c.cust_nam, count(s.qty_sold) as qty_sold Total
from customers c inner join sales s
     on c.cust_id = s.cust_id
where s.sale_dat >= ‘20100101’and  s.sale_dat <= ‘20101231’
group by c.cust_nam