Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

consulta NOT DISTINCT no mySQL


Na descrição da coluna da sua tabela de resultados, não vejo minit, address and number of occurrences . Portanto, eu simplificaria sua seleção para:
SELECT e1.ninumber,
       e1.fname,
       e1.lname,
       e1.superNiNumber,
FROM   employee AS e1,
       employee AS e2
WHERE  e1.dno = 8
       AND e1.superNiNumber = e2.ninumber
       AND e2.dno = 8
       and (select count(*) from employee e3
            where e3.superNiNumber = e1.superNiNumber) > 1;