0

我似乎不知道如何在这上面找到一些东西。这是我的示例,它只显示了重复的列:

select column1,COUNT(column1)
    from table
    where column1> 0
    GROUP BY column1
    HAVING COUNT(column1) > 1

输出:

----------------------------
column1 | (name not defined)
----------------------------
2134567 | 2
2881992 | 3

我想要的是:

------------------------------------------------
column0 | column2 |column1 | (name not defined)
------------------------------------------------
1       |     abc |2134567 | 2
2       |     cde |2881992 | 3

我怎样才能做到这一点?

4

2 回答 2

2

您需要将查询连接回要从中提取附加数据的表

SELECT column0, column2, table.column1, columncount
FROM table 
    INNER JOIN (SELECT column1, COUNT(column1) columncount
                FROM table
                WHERE column1> 0
                GROUP BY column1 HAVING COUNT(column1) > 1) t2 ON table.column1 = t2.column1
于 2013-04-02T18:22:20.623 回答
1

尝试类似:

SELECT * FROM [Tanle1]
WHERE Column0 IN
     (SELECT Column0 FROM [Table1]
      GROUP BY Column0
      HAVING COUNT(Column0) > 1)
于 2013-04-02T18:24:07.893 回答