日期:2014-05-17 浏览次数:20712 次
SELECT * FROM (SELECT TOP 1 * FROM TABLE_A WHERE ORDER BY 日期A) AS TR1 UNION all SELECT * FROM (SELECT TOP 1 * FROM TABLE_B WHERE ORDER BY 日期B) AS TR2;
------解决方案--------------------
注:下面的这种方法不能用。
SELECT * FROM (SELECT TOP 1 * FROM TABLE_A WHERE ORDER BY 日期A) AS TR1 UNION SELECT * FROM (SELECT TOP 1 * FROM TABLE_B WHERE ORDER BY 日期B) AS TR2;
------解决方案--------------------
当然不能用了,ORDER BY 语句前面多了个"WHERE"
------解决方案--------------------
楼主在忽悠人?
------解决方案--------------------
--TRY SELECT TOP 1 * into #t1 FROM TABLE_A WHERE ORDER BY 日期A; SELECT TOP 1 * into #t2 FROM TABLE_B WHERE ORDER BY 日期B; go select * from #t1 union all select * from #t2 drop table #t1 drop table #t2