0

HI,

Am new to PL\SQL. I just want to fetch the 4 fields from employee table. how to do it?

employee_ID, First_name, Last_name, total number of employees from employee table.

i tried to fetch using count() function. but it is not giving the total number of employees.

can anyone please help me?

Thank you.

3
Contributors
2
Replies
11
Views
2 Years
Discussion Span
Last Post by lps
0

I assumed your 'total number of employees' is not stored in database.
You cannot join all these into one query except your employee_ID, First_name, Last_name can be duplicated. For example: if we got 3 rows of employee_ID of 'ID1' and 2 rows of employee_ID of 'ID2', then I will use this query:
SELECT employee_ID,First_name,Last_name,count(employee_ID) FROM employee GROUP BY employee_ID
this will result in:

employee_ID First_name Last_name count(employee_ID)
---------------------------------------------------
ID1         Lau        PS        3
ID2         Clark      Kent      2

while if it cannot be duplicated, means all the count will be value '1'. In this case, what I normally done is with 2 ways:
1. like @JerrimePatient suggested, use 1 query for select 3 data and seperate another query for count(*).
2. Use 1 query for select 3 data(except count) then using the program to count the rows of data retrieved.

Edited by lps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.