两种查询库中重复值的SQL

SELECT *
FROM   (
           SELECT *
                  ,RANK() OVER(ORDER BY who_answ) c2
           FROM   Ft_Question
       ) b
WHERE  b.c2 IN (
                SELECT a.c1
                FROM   (
                           SELECT RANK() OVER(ORDER BY who_answ) AS c1
                           FROM   Ft_Question
                       ) a
                GROUP BY c1
                HAVING Count(c1) > 1)

----------------------
SELECT     id, Tid, question, answer, who_quest, IP_quest, who_answ, state, time_quest, time_answer
FROM         Ft_Question
WHERE     (who_answ IN
                          (SELECT     who_answ
                            FROM          Ft_Question AS Ft_Question_1
                            GROUP BY who_answ
                            HAVING      (COUNT(*) > 1)))

posted @ 2008-11-04 14:53  昕友软件开发  阅读(279)  评论(0编辑  收藏  举报
欢迎访问我的开源项目:xyIM企业即时通讯