New answers tagged row
select x.* from member as x where x.id IN ( select id from member group by id having count(distinct email) > 1 )
Typing from my phone, you could do something like: select x.* from t as x join ( select id from t group by id having count(distinct email) > 1 ) as y on x.id = y.Id You seem to be missing a primary key, but I assume this exercise is part of fixing that.
In Oracle select a.*, b.commission, b.date from sales_staff a, comission b where a.id = b.id;
If you're running on MySQL: SELECT c.ID, ss.LASTNAME, ss.FIRSTNAME, ss.STREET, ss.CITY, ss.STATE, ss.ZIP, GROUP_CONCAT(c.COMMISSION ORDER BY c.DATE SEPARATOR '\n') AS COMMISSION, GROUP_CONCAT(c.DATE ORDER BY c.DATE SEPARATOR '\n') AS DATE FROM db1.Sales_Staff AS ss JOIN db1.Commission AS c ON (c.ID=ss.ID) ORDER BY ...
SELECT DISTINCT ID FROM tbl WHERE DUES = 0 will get the IDs of the naughty people, correct? So now you need to do a "self-JOIN" back to get the rest of the data: SELECT DISTINCT a.* FROM tbl AS a JOIN tbl AS b USING(ID) WHERE b.DUES = 0 ORDER BY a.ID, a.DATE Or... SELECT * FROM tbl AS a WHERE EXISTS ( SELECT ID FROM tbl ...
Top 50 recent answers are included