急!SQL高手请进:通过查询组合字符串的问题!表t 有三个字符串型字段 YYYY,MM,DD.分别代表年、月、日用什么SQL查询一下,把把三个字段组合成日期后显示的值相加后显示?
要求
如:
YYYY MM DD
2004
2005 12 7
2008 8
查询后显示:2004.7
2005.12.7
2008.8谢谢!
要求
如:
YYYY MM DD
2004
2005 12 7
2008 8
查询后显示:2004.7
2005.12.7
2008.8谢谢!
select
(case when to_char(t.YYYY)<>'' or to_char(t.YYYY) is not null then
(case when to_char(t.MM)<>'' or to_char(t.MM) is not null then
(
case when to_char(t.DD)<>'' or to_char(t.DD) is not null then
concat(concat(to_char(t.YYYY),'.'),concat(concat(to_char(t.MM),'.'),to_char(t.DD)))
else
concat(concat(to_char(t.YYYY),'.'),to_char(t.MM)) end
)
else to_char(t.YYYY) end)
else to_char(t.YYYY) end ) as 日期
from t谢谢各位。