-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmissingID.sql
More file actions
33 lines (26 loc) · 951 Bytes
/
missingID.sql
File metadata and controls
33 lines (26 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--Display missing employee IDs.
select max(employee_id),min(employee_id) from employees;
select count(*) from employees where employee_id=104;
select distinct employee_id from employees;
DELETE FROM employees WHERE employees.employee_id = 104;
select count(*),to_char(hire_date,'yyyy')
from employees
group by to_char(hire_date,'yyyy')
having count(*) =
( select max( count(*))
from employees
group by to_char(hire_date,'yyyy'));
declare
v_min employees.employee_id%TYPE ;
v_max employees.employee_id%TYPE ;
cnt number;
begin
select max(employee_id),min(employee_id) into v_max,v_min from employees;
FOR j IN v_min..v_max LOOP
--dbms_output.put_line(j);
select count(*) into cnt from employees where employee_id=j;
if cnt=0 then
dbms_output.put_line(j||' is missing');
end if;
END LOOP;
end;