Practicas Sql - Mauricio Guzman

1,854
-1

Published on

Tarea Mauricio Guzman

Published in: Economy & Finance, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,854
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
63
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Practicas Sql - Mauricio Guzman

  1. 1. ESCUELA SUPERIOR POLITECNICA DEL LITORAL<br />FACULTAD DE INGENIERIA EN ELECTRICIDAD Y COMPUTACION<br />SISTEMAS DE BASES DE DATOS I<br />TRABAJO EN CLASE<br />EJERCICIOS SQL<br />ALUMNO.<br />GUZMAN CONTRERAS MAURICIO<br />PROFESOR. ING. FABRICIO ECHEVERRIA<br />PARALELO. 01<br />GUAYAQUIL, JULIO 22 DE 2009<br />Ejercicios 1.<br />1.<br />select emp_id, emp_fname, emp_lname, salary<br />from employee<br />where salary<(select avg(salary)<br /> from employee)<br />2.<br />select emp_id, emp_fname, emp_lname<br />from employee<br />where dept_id in(select dept_id<br /> from department where dept_name='R & D')<br />3.<br />select emp_id, emp_fname, emp_lname, salary<br />from employee<br />where salary>some(select salary<br /> from employee<br /> where city='Milton')<br />4.<br />select emp_id, emp_fname, emp_lname, salary<br />from employee<br />where salary>all(select salary<br /> from employee<br /> where city='Milton')<br />5.<br />select prod.name, prod.quantity, clte.fname, clte.lname<br />from product prod, customer clte, sales_order salo, sales_order_items sali <br />where clte.id=salo.cust_id and salo.id=sali.id and sali.prod_id=prod.id<br />6.<br />SELECT dep1.dept_name, sum(emp1.salary) as total<br />FROM employee emp1, department dep1<br />where emp1.dept_id = dep1.dept_id<br />group by dep1.dept_name<br />Ejercicios 2.<br />1.<br /> Para la clausula some, la clausula equivalente es between.<br />2. <br />Para la clausula all, la clausula equivalente es max.<br />3.<br />SELECT emp1.emp_fname, emp1.emp_lname<br />FROM employee emp1, department dep1<br />where exists (select * from employee where employee.salary > '80000' and employee.city = 'Milton')<br />4.<br />SELECT emp1.emp_fname, cus.fname<br />FROM employee emp1, customer cus<br />SELECT employee.emp_fname from employee<br />union all<br />select customer.fname from customer<br />5.<br />SELECT employee.city from employee<br />intersect all<br />select customer.city from customer<br />6.<br />SELECT employee.city from employee<br />except all<br />select contact.city from contact<br />1.<br />insert into contact_copy<br />select *<br />from contact<br />2.<br />insert into contact_copy(id, last_name, first_name, title, street, city, state, zip, phone, fax)<br />values (12,'Hildebrand','Jane','ma','280 Washington St.','Kanata','CA','94608','5105551309','5105554209')<br />3.<br />delete from contact_copy<br />4.<br />delete from contact_copy<br />where city like'm%' or city like'l%' or city like'k%'<br />5.<br />insert into employee_copy<br />select *<br />from employee<br />6.<br />insert into employee_copy(emp_id, manager_id, emp_fname, emp_lname, dept_id, street, city, state, zip_code, phone, status, ss_number, salary, start_date, termination_date, birth_date, bene_health_ins, bene_life_ins, bene_day_care, sex)<br />values(310,702,'mauricio','guzman','521','urdesanorte','guay','guaya',012457128,042156789,'z',0124578,400000,'1984-09-12',null,'1972-02-12','d','j','f','m')<br />7.<br />delete <br />from employee_copy<br />where salary<(select 0.5*avg(salary)<br /> from employee_copy)<br />8.<br />update employee_copy set salary= salary+salary*0.2<br />9.<br />update employee_copy set salary= salary+salary*0.1<br />where sex= 'f'<br />10.<br />update employee_copy set salary= salary-1000<br />where salary>(select avg(salary)<br /> from employee_copy)<br />11.<br />select distinct empy.emp_id, empy.emp_fname<br />from employee empy, employee mana<br />where empy.emp_id= mana.manager_id<br />

×