简单的sql语句,由于自己水平一般,不知道错在哪里...忘熟悉语句的人指导一二,谢谢!
select new_name as 年度,
count(new_name) as 总份数,
round(sum(case new_q01 when '0' then filterednew_survey.new_q01
when filterednew_survey.new_q01 is null then '0'
else(filterednew_survey.new_q01-1.00)
end),2) as 产品的销售价格打分
from filterednew_survey
group by new_name
为什么这句提示关键字 'is' 附近有语法错误???
select
new_name as year,
count(new_name) as quantity,
round(sum(isnull(new_q01,1.00)-1.00)/
sum(case
when new_q01 is null then 0
else 1 end ),2) as 产品的销售价格打分
from filterednew_survey
group by new_name
这句没有问题.
select
new_name as year,
count(new_name) as quantity,
round(sum(isnull(new_q01,1.00)-1.00)/
sum(case
when new_q01 is null then 0
else 1 end ),2) as 产品的销售价格打分
from filterednew_survey
group by new_name
这句也没有问题
请各位指导下~~~
经过几位的帮忙,我自己修改了一下,改成
select new_name as 年度,
count(new_name) as 总份数,
round(sum(case new_q01 when '0' then filterednew_survey.new_q01
else (isnull(filterednew_survey.new_q01,1.00)-1.00)
end),2) as 产品的销售价格打分
from filterednew_survey
group by new_name
也重新理解了下isnull
但是有还是有点小小的不明白
select
new_name as year,
count(new_name) as quantity,
round(sum(isnull(new_q01,1.00)-1.00)/
sum(case
when new_q01 is null then 0
else 1 end ),2) as 产品的销售价格打分
from filterednew_survey
group by new_name
为什么这句的也是is null then 0就可以呢?
慕少森
拉风的咖菲猫
相关分类