select 客户表.客户编号, nvl(stat.c,0)from 客户表left join (select 客户编号,sum(商品价格) c from 交易表 group by 客户编号) stat on stat.客户编号=客户表.客户编号