假如有一个字段 name 当name 不为空的时候显示 admin 用哪个函数
解决方案 »
- 如何获取最接近当前时间的记录?
- 主流关系数据库比较
- 一个sql运行错误
- 数据库的查询问题 谢谢了各位
- 数据库查询问题!!!在线等!!帮帮美女!!
- 高分请教 Oralce这行代码有何问题。
- 关于host的使用方法
- Oracle 9i R920 :无法从套接字读取更多的数据 9.2版与9.0版差别
- 各位请帮忙,关于DISTINCT返回多列不重复的结果集,解决了在加分,(用一条sql语句)在线等待
- 一段sql优化问题,查询速度过慢,特别是数据量大的时候
- 用oracle的sql developer连接上SqlServer2005后。没有自己建的数据库。急急急急急。。。在线求教
- 急!如何从一张表的内容追加到另一张表里(字段不一样)?
nvl(name,'admin’)
decode(name,null,为空时需要显示的值,'admin')
case when name is not null then 'admin'
NVL lets you replace a null (blank) with a string in the results of a query.
If expr1 is null, then NVL returns expr2. If expr1 is not null, then NVL returns expr1. The arguments expr1 and expr2 can have any datatype.
If their datatypes are different, then Oracle converts expr2 to the datatype of expr1 before comparing them.The datatype of the return value is always the same as the datatype of expr1, unless expr1 is character data, in which case the return value's datatype is VARCHAR2 and is in the character set of expr1.Examples
The following example returns a list of employee names and commissions, substituting "Not Applicable" if the employee receives no commission:SELECT last_name, NVL(TO_CHAR(commission_pct), 'Not Applicable')
"COMMISSION" FROM employees
WHERE last_name LIKE 'B%'
ORDER BY last_name;
LAST_NAME COMMISSION
------------------------- ----------------------------------------
Baer Not Applicable
Baida Not Applicable
Banda .1
Bates .15
Bell Not Applicable
Bernstein .25
Bissot Not Applicable
Bloom .2
Bull Not Applicable
"COMMISSION" FROM employees
WHERE last_name LIKE 'B%'
ORDER BY last_name;
LAST_NAME COMMISSION
------------------------- ----------------------------------------
Baer Not Applicable
Baida Not Applicable
Banda .1
Bates .15
Bell Not Applicable
Bernstein .25
Bissot Not Applicable
Bloom .2
Bull Not Applicable