which is repeated more than 2 times

  • hi

    Can u please tell me that, how to display the details of emp’s, in which city more than 2 employees are there.

    Ex.

    Eno      ename              City

    1          abc                   hyd

    2          xyz                   pune

    3          opq                  mumbai

    4          raj                    pune

    5          sunil                  hyd

    6          sujan                hyd

     

    in this, I want to display only the employees who are living in pune and hyd. Because in these cities 2 and more employees are there.

    Thanking you.

  • SELECT ename FROM employees WHERE City IN ('Pune', 'hyd')

    Steve

    We need men who can dream of things that never were.

  • Or if you want to list employees in more than one city.

    SELECT ename, city FROM employees GROUP BY ename, city HAVING COUNT(city) > 1

    Steve

    We need men who can dream of things that never were.

  •  

    Or :-

    SELECT ename, city FROM employees GROUP BY ename, city HAVING COUNT(ename) > 1

    just play with it to suit your needs.

    Have fun

     

    Steve

    We need men who can dream of things that never were.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply