回複:Please help in SQL code and Thank you

回答: Please help in SQL code and Thank youluck20102011-01-08 16:28:50

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’

所有跟帖: 

This is correct! -平安是福mtl- 給 平安是福mtl 發送悄悄話 平安是福mtl 的博客首頁 (0 bytes) () 01/09/2011 postreply 08:53:33

這個答案真標準,工整明了。:) -八音澗- 給 八音澗 發送悄悄話 八音澗 的博客首頁 (0 bytes) () 01/09/2011 postreply 18:22:43

請您先登陸,再發跟帖!