SQL SERVER查询语句改成 ORACLE语句报错!!!

ysl817 2008-06-11 01:54:31
各位:
大家好!请问如下SQL SERVER查询语句如何改成 ORACLE语句啊,

select * from (select userid,
case type
when 1 then 'User'
when 2 then 'Group'
else null
end as 'USERTYPE',FIRSTNAME, LASTNAME, EMAIL from Usertab where userid like '%administrator%' ) userTable
where usertype like '%1%'
order by userid

===================================================
oracle提示错误:
ORA-00923: FROM keyword not found where expected
我感觉好像
case type
when 1 then 'User'
when 2 then 'Group'
else null
end as 'USERTYPE'
这句有问题,但是不知道ORACLE中如何写。请各位帮忙,小弟先谢谢了。
...全文
100 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hnkdzhanghui 2008-06-11
  • 打赏
  • 举报
回复
'USERTYPE' 改成USERTYPE 或者"USERTYPE"
linzi 2008-06-11
  • 打赏
  • 举报
回复
'USERTYPE' 不要引号,不过用Decode函数比较简单:
select * from (select userid,
DECODE(type, 1, 'User',2, 'Group', null) as USERTYPE, FIRSTNAME, LASTNAME, EMAIL from Usertab where userid like '%administrator%' ) userTable
where usertype like '%1%'
order by userid
WangZWang 2008-06-11
  • 打赏
  • 举报
回复
select * from (select userid, 
case type
when 1 then 'User'
when 2 then 'Group'
else null
end as USERTYPE,FIRSTNAME, LASTNAME, EMAIL from Usertab
where userid like '%administrator%' ) userTable
where usertype like '%1%'
order by userid
robin_ares 2008-06-11
  • 打赏
  • 举报
回复
'USERTYPE' 不要引号

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧