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