回複:Please help in SQL code and Thank you

來源: 2011-01-08 22:23:49 [博客] [舊帖] [給我悄悄話] 本文已被閱讀:

My version:

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

errors are

1. Wrong: count s.qty_sold

Correct: count(s.qty_sold)

2. Wrong: from customers c and sales s

Correct: "from customers c, sales s

3. Wrong: c.cust_id = s.cust_id,
s.sale_dat >= ‘20100101’,
s.sale_dat <= ‘20101231’

Correct: c.cust_id = s.cust_id and 
s.sale_dat >= ‘20100101’and
s.sale_dat <= ‘20101231’