我有两个数据表 -
TestTable1 TestTable2
---------- ----------
Id Name DealDate Id Name DealDate
1 aaTable 2010-09-22 1 aaTable2 2010-09-23
2 bbTable 2010-09-23 2 bbTable2 2010-09-24
3 ccTable 2010-09-28 3 ccTable2 2010-09-26
4 ddTable 2010-09-25 4 ddTable2 2010-09-27
我只想从 TestTable1 + TestTable2 的结果集中获得 两条最新记录来返回这个 -
Id Name DealDate
4 ccTable 2010-09-28
3 ddTable2 2010-09-27
这是我当前的查询
SELECT TOP 2 * FROM
(
SELECT * FROM
(SELECT TOP 2 Id, Name, DealDate FROM TestTable1 ORDER BY DealDate DESC) T1
UNION ALL
SELECT * FROM
(SELECT TOP 2 Id, Name, DealDate FROM TestTable2 ORDER BY DealDate DESC) T2
) T1T2
ORDER BY DealDate DESC
谁能指导我以更好的方式(性能方面/可读性方面)来实现这一目标?
PS 上面的表格只是为了展示用例,我的实际表格有数千条记录。
谢谢!