我似乎无法知道如何在此找到一些东西。 这是我的例子,它只显示了重复的列:
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
我怎样才能做到这一点?
答案 0 :(得分: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
答案 1 :(得分:1)
尝试类似:
SELECT * FROM [Tanle1]
WHERE Column0 IN
(SELECT Column0 FROM [Table1]
GROUP BY Column0
HAVING COUNT(Column0) > 1)