我担心以下查询的表现:
SELECT
MAX(CAST((CONVERT(bigint, DBTimeStamp)) AS decimal)) AS DBTimeStamp
FROM Category
WHERE DepartmentID = 5
是否有更快的方法可以从表中获取最大/最新时间戳作为整数?
答案 0 :(得分:0)
如果计算转换和转换的最大值,则SQL可以使用索引,只需要转换和转换一次:
SELECT
CAST(CONVERT(bigint,MAX( DBTimeStamp)) AS decimal) AS DBTimeStamp
FROM Category
WHERE DepartmentID = 5