You are on page 1of 1

select cm.cust_first_name ||' '|| cm.cust_last_name nombre,count(od.

order_id)
num_ordenes from customers cm
join orders od on cm.customer_id = od.customer_id
join employees ee on cm.account_mgr_id = ee.employee_id
join departments dp on ee.department_id = dp.department_id
join locations lc on dp.location_id = lc.location_id
join countries ct on lc.country_id = ct.country_id
where ct.country_id = 'UK' and od.order_date >= to_date('01/01/2000','DD/MM/YYYY')
group by cm.cust_first_name ||' '|| cm.cust_last_name

select distinct employee_id from job_history

select ee.first_name,round(ee.salary/12,2) from employees ee

SELECT to_char(end_date,'dd'), count(to_char(end_date,'dd')) as conteo


FROM hr.job_history GROUP BY to_char(end_date,'dd')
HAVING count(to_char(end_date,'dd'))>1;

select product_id from product_information

select pi.product_id,oo.order_date,count(oo.order_id),count(oi.product_id),
case
when count(oo.order_id)> count(oi.product_id) then 'descuento'
when count(oo.order_id)< count(oi.product_id) then 'recargo'
else 'igual'
end as verificacion
from product_information pi
join order_items oi on pi.product_id = oi.product_id
join orders oo on oi.order_id = oo.order_id
join employees ee on oo.sales_rep_id = ee.employee_id
join departments dd on ee.department_id = dd.department_id
join locations lc on dd.location_id = lc.location_id
join countries cc on lc.country_id = cc.country_id
where cc.country_id = 'UK' and oo.order_date >= date '2007-01-01' and oo.order_date
<= date '2007-12-31'
group by pi.product_id,oo.order_date;

You might also like