You can write like this

來源: 2011-01-08 20:49:17 [舊帖] [給我悄悄話] 本文已被閱讀:

I didn't try to run, but I think you can get the idea if I have some syntax error:

select
c.cust_nam, 
totqty
from
customers c join

(select sum(s.qty_sold) as totqty, cust_id from sales s
where s.sale_dat >= ‘20100101’,
s.sale_dat <= ‘20101231’ group by
cust_id) cnt
c.cust_id = cnt.cust_id,