In a single table,How to retrieve a employee-id of an
employee who works in more than one department?

Answer Posted / millar

select employee_id,department_id from emp where employee_id in(select employee_id from emp where department_id in (select distinct
department_id from emp) group by employee_id,department_id having count(*) >1);

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define db2.

672


Which component is responsible for db2 startup and shutdown?

628


Comment whether the cursor is closed during commit or not.

673


What is explain in db2?

583


Why cursor is used in db2?

572






How can the duplicate values be eliminated from db2 select?

625


How to run db2 command in windows?

648


What are db2 tables?

647


What is view db2?

624


What is db2 catalog database?

582


What is the difference between "db2ilist" and "db2 get instance" commands in DB2 Database Server?

710


Where can you declare a cursor in a cobol-db2 program?

602


What is alias in db2?

568


How do you concatenate the firstname and lastname from emp table to give a complete name?

602


What is runstats utility in db2?

569