SQL Server中的DECODE?“

编程入门 行业动态 更新时间:2024-10-20 20:55:11
本文介绍了SQL Server中的DECODE?“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

SQL中的函数与Oracle中的DECODE一样有效吗? 谢谢, N

解决方案

使用案例 - David Portas SQL Server MVP -

当Assignment_Type ='''C''那时'选择案例'''''''''''''''''''''' 'Donot Know'' 来自分配 当我尝试使用CASE WHEN时,它给了我错误[Microsoft] [ODBC SQL Server Driver] [SQL Server]关键字''FROM'附近的语法不正确。我做了什么 错了? 谢谢 " David Portas" < RE **************************** @ acm>在消息中写道 news:24 ******************** @ giganews ...

使用案例 - David Portas SQL Server MVP -

>我做了什么

错了?

你没有先读完语法!我的回复是作为你应该查找的东西的 指示。如果你偶尔提到它,你会发现在线书籍是一个很好的资源:-) 选择案例当Assignment_Type ='''C''那么''''''''''''''''''''''''''$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $选择案例Assignment_Type当''C''那么'''''''''''''''''''''''''''''''''$ $ $ $ $ $ $ $ b b b b b b b b b /> David Portas SQL Server MVP -

What is the function in SQL that works like DECODE in Oracle?" Thanks, N

解决方案

Use CASE -- David Portas SQL Server MVP --

SELECT CASE WHEN Assignment_Type = ''C'' THEN ''Com'' ELSE ''Donot Know'' FROM ASSIGNMENT When I try to use CASE WHEN, it gave me error [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword ''FROM''. What did I do wrong? Thanks "David Portas" <RE****************************@acm> wrote in message news:24********************@giganews...

Use CASE -- David Portas SQL Server MVP --

> What did I do

wrong?

You didn''t read-up on the syntax first! My reply was intended as an indication of something you should look up. You''ll find Books Online is a great resource if you refer to it occassionally :-) SELECT CASE WHEN Assignment_Type = ''C'' THEN ''Com'' ELSE ''Do not know'' END FROM ASSIGNMENT or SELECT CASE Assignment_Type WHEN ''C'' THEN ''Com'' ELSE ''Do not know'' END FROM ASSIGNMENT -- David Portas SQL Server MVP --

更多推荐

SQL Server中的DECODE?“

本文发布于:2023-10-27 11:16:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SQL   Server   DECODE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!