Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

query to count number of employees that joined

665974Oct 31 2008 — edited Oct 31 2008
Hi,

i have three tables representing 3 types of employees in a company.

Table 1: Adminstaff
Table 2: ITStaff
Table 3: Clerk

in each of these tables i have an attribute that stores the date of the employment start (e.g. 11/10/2007)
and each table has a primary key attribute empno.

now i would like to write a query that shows me the number of employees that joined in a specific year.

like 2 joined in 2008
5 joined in 2007 ....

i know how to write the query for one table but dont understand how to connect/join all three tables.
select count(empno), to_char(emp_start,'yyyy') from adminstaff group by to_char(emp_start,'yyyy') order by count(empno) desc;
i was trying to use UNION but that gives me year and sum of each table.

thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2008
Added on Oct 31 2008
2 comments
1,330 views