求大神帮忙分析分析,该代码有点问题
select substr(to_char(update_time,'yyyy-mm-dd'),1,7) as 月份,(case
when trunc(pm)<70 then '功率小于70'
when trunc(pm)=70 then '功率70'
when trunc(pm)=71 then '功率71'
when trunc(pm)=72 then '功率72'
when trunc(pm)=73 then '功率73'
when trunc(pm)=74 then '功率74'
when trunc(pm)=75 then '功率75'
else '功率大于76'
end
) as '功率分布情况',count(pm)
from g_test
group by substr(to_char(update_time,'yyyy-mm-dd'),1,7),'功率分布情况'
where substr(to_char(update_time,'yyyy-mm-dd'),1,7) between '201301' and '201305'
order by substr(to_char(update_time,'yyyy-mm-dd'),1,7),'功率分布情况'
;
第 12 行出现错误:
ORA-00923: 未找到要求的 FROM 关键字 {:soso_e120:}才看到你的帖子 你的where 条件写到了group 的后面了。 wangqun_chit 发表于 2013-8-13 11:15 static/image/common/back.gif
才看到你的帖子
呵呵 谢谢啊 acbc1014 发表于 2013-8-26 14:14 static/image/common/back.gif
你的where 条件写到了group 的后面了。
不是那个问题的 我给你改了下,你试试看。:lol
select a.pmonth 月份, a.powerdis 功率分布情况, count(1)
from (select substr(to_char(update_time, 'yyyymmdd'), 1, 6) as pmonth,
(case
when trunc(pm) < 70 then
'功率小于70'
when trunc(pm) = 70 then
'功率70'
when trunc(pm) = 71 then
'功率71'
when trunc(pm) = 72 then
'功率72'
when trunc(pm) = 73 then
'功率73'
when trunc(pm) = 74 then
'功率74'
when trunc(pm) = 75 then
'功率75'
else
'功率大于76'
end) as powerdis
from g_test
where substr(to_char(update_time, 'yyyymmdd'), 1, 6) between
'201301' and '201305') a
group by a.pmonth, a.powerdis
order by a.pmonth, a.powerdis;
select a.pmonth 月份, a.powerdis 功率分布情况, count(1)
from (select substr(to_char(update_time, 'yyyymmdd'), 1, 6) as pmonth,
(case
when trunc(pm) < 70 then
'功率小于70'
when trunc(pm) = 70 then
'功率70'
when trunc(pm) = 71 then
'功率71'
when trunc(pm) = 72 then
'功率72'
when trunc(pm) = 73 then
'功率73'
when trunc(pm) = 74 then
'功率74'
when trunc(pm) = 75 then
'功率75'
else
'功率大于76'
end) as powerdis
from g_test
where substr(to_char(update_time, 'yyyymmdd'), 1, 6) between
'201301' and '201305') a
group by a.pmonth, a.powerdis
order by a.pmonth, a.powerdis; :D 新手学习路过
页:
[1]