select
case when t2.code =10 then
case when t1.price_type=2 then '单价'
else '价格'
end
------------------------------------
else case when t2.code = 20
then t2.name||'(有或无或免)'
else t2.name
end
end
as name1,t2.type
from XXX t1,SSS t2
where t1.id = t2.id and t1.object_id=99 --------------------
谁帮我排一下格式,嵌套的时候,我有点乱。
case when t2.code =10 then
case when t1.price_type=2 then '单价'
else '价格'
end
------------------------------------
else case when t2.code = 20
then t2.name||'(有或无或免)'
else t2.name
end
end
as name1,t2.type
from XXX t1,SSS t2
where t1.id = t2.id and t1.object_id=99 --------------------
谁帮我排一下格式,嵌套的时候,我有点乱。
解决方案 »
- 创建回滚段时minextents 和 maxextents 的值是什么意呀是什么的最大值和最小值呀。
- 新手oracle导出数据库错误,各位帮帮忙
- oracle 字符串替换优化问题
- C# 操作oracle date时间问题!
- 听说有索引视图?请教高手指点下怎么建立?
- 索引的起用
- 我写个包,主要功能是从数据库中读数据,然后存到文件中,编译通过,数据也取出来了,但为什么写不到文件中呢?
- 这样的sql语句怎么写啊?
- 使用exp导出数据库,我只想导出每个表的前100行数据,如果这个表没有100行数据,那就全部导出,该怎么写?
- 如何关闭并开启Oracle 9i的本地服务?
- 从一张表的一个字段赋值到另一张表,两张表通过一个字段关联,这样的SQL怎么写呢?
- oracle分批提交 剩余数据如何处理
SELECT CASE
WHEN t2.code = 10
THEN CASE
WHEN t1.price_type = 2
THEN '单价'
ELSE '价格'
END
ELSE CASE
WHEN t2.code = 20
THEN t2.NAME || '(有或无或免)'
ELSE t2.NAME
END
END AS name1,
t2.TYPE
FROM xxx t1, sss t2
WHERE t1.ID = t2.ID AND t1.object_id = 99
SELECT CASE
WHEN t2.code = 10
THEN
CASE
WHEN t1.price_type = 2
THEN '单价'
ELSE '价格'
END
ELSE
CASE
WHEN t2.code = 20
THEN t2.NAME || '(有或无或免)'
ELSE t2.NAME
END
END AS name1,
t2.TYPE
FROM xxx t1, sss t2
WHERE t1.ID = t2.ID AND t1.object_id = 99
case
when t2.code =10 then
case when t1.price_type=2 then '单价' else '价格' end
else
case when t2.code = 20 then t2.name||'(有或无或免)' else t2.name end
end
as name1,t2.type
from XXX t1,SSS t2
where t1.id = t2.id and t1.object_id=99
select
case when t2.code =10 then
case when t1.price_type=2 then '单价' else '价格' end
else
case when t2.code = 20 then t2.name||'(有或无或免)' else t2.name end
end as name1, t2.type
from XXX t1,SSS t2
where t1.id = t2.id and t1.object_id=99
case when t2.code =10 then
case when t1.price_type=2 then '单价' else '价格' end
else case when t2.code = 20 then
t2.name||'(有或无或免)'
else t2.name end
end as name1,
t2.type
from XXX t1,SSS t2
where t1.id = t2.id and t1.object_id=99
其实要是看着不方便的话,可以考虑用一下Decode()函数
select
Decode(
t2.code,
10,Decode(t1.price_type,2,'单价','价格'),
20,t2.name||'(有或无或免)',
t2.name
) as name1,
t2.type
from XXX t1,SSS t2
where t1.id = t2.id and t1.object_id=99
这个SQL的执行效率可能会比上一个高一些