2013-03-20 71 views
-1

所以我现在有我的查询读取HD0/HD1/HD2/HD3/HD4但遇到问题,其中如果我有一个空值,然后重复// ei。 HD0 /// HD3/ 任何想法案件陈述采取null

Hd0 
||'/'|| 
Case 
When table.hd1 <>00 
then HD1_ABR 
end 
||'/'|| 
case 
When hd2 <>00 
then HD2_name 
end 
||'/'|| 
case 
When hd3 <>00 
then HD3_name 
end 
||'/'|| 
case 
When hd4 <>00 
then HD4_name 
end) as Name, 
+2

拆开你的第一个'CASE'声明,你说:“如果'HD1 ''不是零,那么'HD1_ABR'也是NULL,其他的都是相似的,Oracle给你的是你所要求的,如果'hd1'(或'hd2'或'hd3'或' hd4')*是*零? – 2013-03-20 13:42:06

+0

如果它的零我不想要任何值,但我也不想要th /跟在HD – SMD27 2013-03-20 13:49:34

+0

好的,在这种情况下,@DazzaL的答案是你想要的。诀窍是移动'/'里面'CASE'。 – 2013-03-20 13:54:25

回答

1

,如果我理解正确的话,您可以将您的情况下改变

rtrim(Hd0 
||'/'|| 
Case 
When table.hd1 <>00 
then HD1_ABR ||'/' 
end 
|| 
case 
When hd2 <>00 
then HD2_name||'/' 
end 
|| 
case 
When hd3 <>00 
then HD3_name||'/' 
end 
|| 
case 
When hd4 <>00 
then HD4_name 
end, '/') as Name, 
+0

谢谢你似乎工作 – SMD27 2013-03-20 13:57:40