Join and GROUP BY
create table ord(
order_no integer primary key
,order_date date not null
,emp_no number(3,0)
);
create table department(
dept_no integer primary key
,dept_name varchar(20) not null
);
create table employee(
emp_no integer primary key
,lastname varchar2(20) not null
,dept_no integer
);
select d.dept_name,
e.lastname AS sales_name,
o.order_date,
count(*)
from department d, employee e, ord o
where d.dept_no = e.dept_no
and e.emp_no = o.emp_no
group by d.dept_name, e.lastname, o.order_date;
drop table ord;
drop table employee;
drop table department;
Related examples in the same category