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