日期:2014-05-18 浏览次数:20511 次
select *,id = identity(int,1,1) into #tb from( select .. from tb1 union all select .. from tb2 )t
------解决方案--------------------
CREATE VIEW
AS
SELECT * FROM
(SELECT col ,
(SELECT COUNT(*) FROM
(SELECT col FROM t1 UNION ALL SELECT col FROM t2) AS A2
WHERE A2.col<A1.col) AS RANK
FROM (SELECT col FROM t1 UNION ALL SELECT col FROM t2) AS A1) AS B
ORDER BY RANK
------解决方案--------------------
在2000环境下验证通过.
CREATE VIEW AS SELECT * FROM (SELECT col , (SELECT COUNT(*) FROM (SELECT col FROM t1 UNION ALL SELECT col FROM t2) AS A2 WHERE A2.col<A1.col) AS RANK FROM (SELECT col FROM t1 UNION ALL SELECT col FROM t2) AS A1) AS B ORDER BY RANK