Select supplierno as Supplier, duedate as date
from table
union
Select supplierno as Supplier, duedate as date
from table
Union
-----New union
order by 2
结果如下:
Supplier date
5000 2014-10-05 00-00-00-000
5010 2014-05-05 00-00-00-000
我必须使用datetime才能正确排序。 如何在结果中更好地格式化日期?
我想要这个:
Supplier date
5000 05.10.2014
5010 05.05.2014
答案 0 :(得分:0)
如果所有表日期都采用日期时间格式,则以下内容应该有效:
;with CTE
AS
(
Select supplierno as Supplier, duedate as date
from table
union
Select supplierno as Supplier, duedate as date
from table
Union
-----New union
order by 2
)
select
Supplier, convert(varchar(100), [date], 104)
from cte