我想确定哪些表中包含最早的记录。为此,我想我可以说:
SELECT TOP 1 TableName FROM
(
SELECT CreateDate, 'Table1' as TableName FROM Table1
UNION
SELECT CreateDate, 'Table2' as TableName FROM Table2
)
ORDER BY CreateDate
在 SQL Server 2008R2 中,它告诉我“ORDER”附近存在语法错误。
有任何想法吗?