SlideShare une entreprise Scribd logo
1  sur  13
ESCUELA SUPERIOR POLITECNICA DEL LITORAL FACULTAD DE INGENIERIA EN ELECTRICIDAD Y COMPUTACION SISTEMAS DE BASES DE DATOS I TRABAJO EN CLASE EJERCICIOS SQL ALUMNO. GUZMAN CONTRERAS MAURICIO PROFESOR. ING. FABRICIO ECHEVERRIA PARALELO. 01 GUAYAQUIL, JULIO 22 DE 2009 Ejercicios 1. 1. select emp_id, emp_fname, emp_lname, salary from employee where salary<(select avg(salary)               from employee) 2. select emp_id, emp_fname, emp_lname from employee where dept_id in(select dept_id               from department  where dept_name='R & D') 3. select  emp_id, emp_fname, emp_lname, salary from employee where salary>some(select salary                  from employee                  where city='Milton') 4. select  emp_id, emp_fname, emp_lname, salary from employee where salary>all(select salary                  from employee                  where city='Milton') 5. select  prod.name, prod.quantity, clte.fname, clte.lname from 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.id 6. SELECT dep1.dept_name, sum(emp1.salary) as total FROM employee emp1, department dep1 where emp1.dept_id = dep1.dept_id group by dep1.dept_name Ejercicios 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_lname FROM employee emp1, department dep1 where exists (select * from employee where employee.salary > '80000' and employee.city = 'Milton') 4. SELECT emp1.emp_fname, cus.fname FROM employee emp1, customer cus SELECT employee.emp_fname from employee union all select customer.fname from customer 5. SELECT employee.city from employee intersect all select customer.city from customer 6. SELECT employee.city from employee except all select contact.city from contact 1. insert into contact_copy select * from contact 2. 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_copy 4. delete from contact_copy where city like'm%' or city like'l%' or city like'k%' 5. insert into employee_copy select * from employee 6. 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_copy where salary<(select 0.5*avg(salary)               from employee_copy) 8. update employee_copy set salary= salary+salary*0.2 9. update employee_copy set salary= salary+salary*0.1 where sex= 'f' 10. update employee_copy set salary= salary-1000 where salary>(select avg(salary)               from employee_copy) 11. select distinct empy.emp_id, empy.emp_fname from employee empy, employee mana where 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

Contenu connexe

Dernier

20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdf20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdf
Adnet Communications
 
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
dipikadinghjn ( Why You Choose Us? ) Escorts
 
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
dipikadinghjn ( Why You Choose Us? ) Escorts
 

Dernier (20)

The Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdfThe Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdf
 
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
 
The Economic History of the U.S. Lecture 20.pdf
The Economic History of the U.S. Lecture 20.pdfThe Economic History of the U.S. Lecture 20.pdf
The Economic History of the U.S. Lecture 20.pdf
 
03_Emmanuel Ndiaye_Degroof Petercam.pptx
03_Emmanuel Ndiaye_Degroof Petercam.pptx03_Emmanuel Ndiaye_Degroof Petercam.pptx
03_Emmanuel Ndiaye_Degroof Petercam.pptx
 
The Economic History of the U.S. Lecture 21.pdf
The Economic History of the U.S. Lecture 21.pdfThe Economic History of the U.S. Lecture 21.pdf
The Economic History of the U.S. Lecture 21.pdf
 
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
 
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
 
Veritas Interim Report 1 January–31 March 2024
Veritas Interim Report 1 January–31 March 2024Veritas Interim Report 1 January–31 March 2024
Veritas Interim Report 1 January–31 March 2024
 
20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdf20240429 Calibre April 2024 Investor Presentation.pdf
20240429 Calibre April 2024 Investor Presentation.pdf
 
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
 
The Economic History of the U.S. Lecture 23.pdf
The Economic History of the U.S. Lecture 23.pdfThe Economic History of the U.S. Lecture 23.pdf
The Economic History of the U.S. Lecture 23.pdf
 
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfThe Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdf
 
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
 
Indore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdfIndore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdf
 
(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7
(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7
(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7
 
Stock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdfStock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdf
 
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure serviceCall US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
 
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
 

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Practicas En Clase Sql

  • 1. ESCUELA SUPERIOR POLITECNICA DEL LITORAL FACULTAD DE INGENIERIA EN ELECTRICIDAD Y COMPUTACION SISTEMAS DE BASES DE DATOS I TRABAJO EN CLASE EJERCICIOS SQL ALUMNO. GUZMAN CONTRERAS MAURICIO PROFESOR. ING. FABRICIO ECHEVERRIA PARALELO. 01 GUAYAQUIL, JULIO 22 DE 2009 Ejercicios 1. 1. select emp_id, emp_fname, emp_lname, salary from employee where salary<(select avg(salary) from employee) 2. select emp_id, emp_fname, emp_lname from employee where dept_id in(select dept_id from department where dept_name='R & D') 3. select emp_id, emp_fname, emp_lname, salary from employee where salary>some(select salary from employee where city='Milton') 4. select emp_id, emp_fname, emp_lname, salary from employee where salary>all(select salary from employee where city='Milton') 5. select prod.name, prod.quantity, clte.fname, clte.lname from 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.id 6. SELECT dep1.dept_name, sum(emp1.salary) as total FROM employee emp1, department dep1 where emp1.dept_id = dep1.dept_id group by dep1.dept_name Ejercicios 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_lname FROM employee emp1, department dep1 where exists (select * from employee where employee.salary > '80000' and employee.city = 'Milton') 4. SELECT emp1.emp_fname, cus.fname FROM employee emp1, customer cus SELECT employee.emp_fname from employee union all select customer.fname from customer 5. SELECT employee.city from employee intersect all select customer.city from customer 6. SELECT employee.city from employee except all select contact.city from contact 1. insert into contact_copy select * from contact 2. 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_copy 4. delete from contact_copy where city like'm%' or city like'l%' or city like'k%' 5. insert into employee_copy select * from employee 6. 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_copy where salary<(select 0.5*avg(salary) from employee_copy) 8. update employee_copy set salary= salary+salary*0.2 9. update employee_copy set salary= salary+salary*0.1 where sex= 'f' 10. update employee_copy set salary= salary-1000 where salary>(select avg(salary) from employee_copy) 11. select distinct empy.emp_id, empy.emp_fname from employee empy, employee mana where empy.emp_id= mana.manager_id