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 --------------------
谁帮我排一下格式,嵌套的时候,我有点乱。
解决方案 »
- willnum>(select avg(willnum),couname,couno from course问题
- 请高手指点一个sql!
- 在定义表时,用varchar和varchar2之间有什么区别?
- exp能够导出用户下的包吗?
- 数据库里sysdate是0005-3-7,怎么处理成2005-3-7,真的蛮急的
- 求ORACLE报的代码错误信息详细解释?
- 求一个SQL,执行成功,立即结贴
- 一台机器可以装两个ORACLE吗(8.1.6和7.0.3)?
- 关于oracle数据库0001文件的处理方式
- oracle数据库远程连接失败
- 从一张表的一个字段赋值到另一张表,两张表通过一个字段关联,这样的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的执行效率可能会比上一个高一些