返回重复的生产商很容易,使用分组
having count(*) > 1
即可。
很好的开端。现在使用那个manufacture
列表来选择剩余的数据:
SELECT *
FROM software
WHERE manufacture IN (
-- This is your "HAVING COUNT(*) > 1" query inside.
-- It drives the selection of rows in the outer query.
SELECT manufacture
FROM software
GROUP BY manufacture
HAVING COUNT(*) > 1
)
Select * from myTable
Where Manufacture In
(Select Manufacture
from myTable
Group By Manufacture
Having count(*) > 1)
你尝试过类似这样的东西吗:
select p.manufacture, p.product, p.version
from (select manufacture, count(*)
from products
group by manufacture) as my_count
inner join products as p on p.manufacture = my_count.manufacture
where my_count > 1