select * from (
SELECT top 3 Ref_Date, COUNT(Ref_Date) AS Count, 'Trim' as Ref_DateTrimmed
FROM [STORAGE_DW].[dbo].[SRM_VirtualMachines]
group by Ref_Date
order by Ref_Date desc
) a
UNION
select * from (
SELECT top 3 Ref_Date, COUNT(Ref_Date) AS Count, 'Trim' as Ref_DateTrimmed
FROM [STORAGE_DW].[dbo].[SRM_PhysicalHosts]
group by Ref_Date
order by Ref_Date desc
) b
返回的列是这样的:
Ref_Date
2017-01-16 02:27:00.000
2017-01-16 07:05:00.000
2017-01-23 02:24:00.000
2017-01-23 07:01:00.000
2017-01-30 02:36:00.000
2017-01-30 07:03:00.000
答案 0 :(得分:1)
You can use this: CONVERT(DATE, Ref_Date, 101) as 'Trim'