sql - How to find rows with duplicate columns in a subquery? -
i working data in eve static dump , ms sql server express.
the dump contains table mapdenormalize, having columns named solarsystemid , typeid, both of ints (and neither of key). i'm trying find values of solarsystemid appear more once, various combinations of typeid.
i have query
-- systems have plasma or temperate planet select distinct d.solarsystemid, d.typeid mapdenormalize d join invtypes t on d.typeid = t.typeid t.typename in ('planet (plasma)', 'planet (temperate)') order solarsystemid which returns 1 row each solarsystemid has plasma planet , 1 row each temperate planet. trying figure out how use subquery find solarsystemids have both kinds of planets, have come empty-handed.
i started out thinking like
select solarsystemid ( above query ) count(solarsystemid) > 1 but doesn't parse. correct approach?
select d.solarsystemid, count(d.solarsystemid) counts mapdenormalize d join invtypes t on d.typeid = t.typeid t.typename in ('planet (plasma)', 'planet (temperate)') group d.solarsystemid having count(d.solarsystemid) > 1;
Comments
Post a Comment