日期:2014-05-17 浏览次数:20360 次
WITH cte AS ( SELECT 'A' AS team UNION ALL SELECT 'B' UNION ALL SELECT 'C' UNION ALL SELECT 'D' ) SELECT * FROM cte a,cte b WHERE a.team<b.team /* team team A B A C A D B C B D C D */
------解决方案--------------------
IF object_id('tc') IS NOT NULL DROP TABLE tc GO CREATE TABLE tc ( team VARCHAR(10)) INSERT INTO tc SELECT 'A' UNION ALL SELECT 'B' UNION ALL SELECT 'C' UNION ALL SELECT 'D' SELECT Count(1) FROM tc a INNER JOIN tc b ON a.team < b.team