ESCUELA SUPERIOR POLITECNICA DEL LITORALFACULTAD DE INGENIERIA EN ELECTRICIDAD Y COMPUTACIONSISTEMAS DE BASES DE DATOS ITRABAJO EN CLASEEJERCICIOS SQLALUMNO.GUZMAN CONTRERAS MAURICIOPROFESOR. ING. FABRICIO ECHEVERRIAPARALELO. 01GUAYAQUIL, JULIO 22 DE 2009Ejercicios 1.1.select emp_id, emp_fname, emp_lname, salaryfrom employeewhere salary              from employee)2.select emp_id, emp_fname, emp_lnamefrom employeewhere dept_id in(select dept_id              from department  where dept_name='R & D')3.select  emp_id, emp_fname, emp_lname, salaryfrom employeewhere salary>some(select salary                 from employee                 where city='Milton')4.select  emp_id, emp_fname, emp_lname, salaryfrom employeewhere salary>all(select salary                 from employee                 where city='Milton')5.select  prod.name, prod.quantity, clte.fname, clte.lnamefrom product prod, customer clte, sales_order salo, sales_order_items sali where clte.id=salo.cust_id and salo.id=sali.id and sali.prod_id=prod.id6.SELECT dep1.dept_name, sum(emp1.salary) as totalFROM employee emp1, department dep1where emp1.dept_id = dep1.dept_idgroup by dep1.dept_nameEjercicios 2.1. Para la clausula some, la clausula equivalente es between.2. Para la clausula all, la clausula equivalente es max.3.SELECT emp1.emp_fname, emp1.emp_lnameFROM employee emp1, department dep1where exists (select * from employee where employee.salary > '80000' and employee.city = 'Milton')4.SELECT emp1.emp_fname, cus.fnameFROM employee emp1, customer cusSELECT employee.emp_fname from employeeunion allselect customer.fname from customer5.SELECT employee.city from employeeintersect allselect customer.city from customer6.SELECT employee.city from employeeexcept allselect contact.city from contact1.insert into contact_copyselect *from contact2.insert into contact_copy(id, last_name, first_name, title, street, city, state, zip, phone, fax)values (12,'Hildebrand','Jane','ma','280 Washington St.','Kanata','CA','94608','5105551309','5105554209')3.delete from contact_copy4.delete from contact_copywhere city like'm%' or city like'l%' or city like'k%'5.insert into employee_copyselect *from employee6.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)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')7.delete from employee_copywhere salary              from employee_copy)8.update employee_copy set salary= salary+salary*0.29.update employee_copy set salary= salary+salary*0.1where sex= 'f'10.update employee_copy set salary= salary-1000where salary>(select avg(salary)              from employee_copy)11.select distinct empy.emp_id, empy.emp_fnamefrom employee empy, employee manawhere empy.emp_id= mana.manager_id
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql
Practicas En Clase Sql

Practicas En Clase Sql

  • 1.
    ESCUELA SUPERIOR POLITECNICADEL LITORALFACULTAD DE INGENIERIA EN ELECTRICIDAD Y COMPUTACIONSISTEMAS DE BASES DE DATOS ITRABAJO EN CLASEEJERCICIOS SQLALUMNO.GUZMAN CONTRERAS MAURICIOPROFESOR. ING. FABRICIO ECHEVERRIAPARALELO. 01GUAYAQUIL, JULIO 22 DE 2009Ejercicios 1.1.select emp_id, emp_fname, emp_lname, salaryfrom employeewhere salary from employee)2.select emp_id, emp_fname, emp_lnamefrom employeewhere dept_id in(select dept_id from department where dept_name='R & D')3.select emp_id, emp_fname, emp_lname, salaryfrom employeewhere salary>some(select salary from employee where city='Milton')4.select emp_id, emp_fname, emp_lname, salaryfrom employeewhere salary>all(select salary from employee where city='Milton')5.select prod.name, prod.quantity, clte.fname, clte.lnamefrom product prod, customer clte, sales_order salo, sales_order_items sali where clte.id=salo.cust_id and salo.id=sali.id and sali.prod_id=prod.id6.SELECT dep1.dept_name, sum(emp1.salary) as totalFROM employee emp1, department dep1where emp1.dept_id = dep1.dept_idgroup by dep1.dept_nameEjercicios 2.1. Para la clausula some, la clausula equivalente es between.2. Para la clausula all, la clausula equivalente es max.3.SELECT emp1.emp_fname, emp1.emp_lnameFROM employee emp1, department dep1where exists (select * from employee where employee.salary > '80000' and employee.city = 'Milton')4.SELECT emp1.emp_fname, cus.fnameFROM employee emp1, customer cusSELECT employee.emp_fname from employeeunion allselect customer.fname from customer5.SELECT employee.city from employeeintersect allselect customer.city from customer6.SELECT employee.city from employeeexcept allselect contact.city from contact1.insert into contact_copyselect *from contact2.insert into contact_copy(id, last_name, first_name, title, street, city, state, zip, phone, fax)values (12,'Hildebrand','Jane','ma','280 Washington St.','Kanata','CA','94608','5105551309','5105554209')3.delete from contact_copy4.delete from contact_copywhere city like'm%' or city like'l%' or city like'k%'5.insert into employee_copyselect *from employee6.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)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')7.delete from employee_copywhere salary from employee_copy)8.update employee_copy set salary= salary+salary*0.29.update employee_copy set salary= salary+salary*0.1where sex= 'f'10.update employee_copy set salary= salary-1000where salary>(select avg(salary) from employee_copy)11.select distinct empy.emp_id, empy.emp_fnamefrom employee empy, employee manawhere empy.emp_id= mana.manager_id