当前位置:数据库 > Oracle >>

那是什么数据库的SQL语句。我用的Oracle

追问:year as '年' * ERROR at line 2: ORA-00923: FROM keyword not found where expected是的copy的 SQL> select 2 year as '年', 3 decode(month,1,amount) as '一月', 4 decode(month,2,amount) as '二月', 5 decode(month,3,amount) as '三月', 6 decode(month,4,amount) as '四月' 7 from yma 8 group by year; year as '年', * ERROR at line 2: ORA-00923: FROM keyword not found where expectedSQL> select 2 year as '年', 3 decode(month,1,sum(amount)) as '一月', 4 decode(month,2,sum(amount)) as '二月', 5 decode(month,3,sum(amount)) as '三月', 6 decode(month,4,sum(amount)) as '四月' 7 from yma 8 group by year,month ; year as '年', * ERROR at line 2: ORA-00923: FROM keyword not found where expectedSQL> create table yma 2 ( 3 year number(4), 4 month number(2), 5 amount number 6 ); Table created.错误依旧一样select year as '年', decode(month,1,amount) as '一月', decode(month,2,amount) as '二月', decode(month,3,amount) as '三月', decode(month,4,amount) as '四月' from table group by year 黏贴到oracle上不行year as '年', * ERROR at line 2: ORA-00923: FROM keyword not found where expected
答案:oracle应该是可以用的,你看看表名、字段有没有写错。报错的具体内容贴出来看看。 
select 
year as '年',
decode(month,1,sum(amount)) as '一月',
decode(month,2,sum(amount)) as '二月',
decode(month,3,sum(amount)) as '三月',
decode(month,4,sum(amount)) as '四月'
from table
group by year,month
其他:找到后缀就能知道是什么样的数据库!你的是什么样的数据库后缀? 那就是oracle的啊。。。decode

上一个:在线等!!如何通过主表及其主键查询到与之关联的表及关联字段?数据库为oracle
下一个:ORACLE数据库设计的一、二、三范式、BCNF是什么?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,