Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
UNIVERSIDAD
      VERACRUZANA


  Facultad de Administración



Experiencia:
  •   Base de datos



Alumno:
  •   Lara Lóp...
DIAGRAMA




BRANCH
  BRANCH_ID                                                             EMPLOYEE
  NAME               ...
EJERCICIOS DE SQL

                                 (OPCIONALES.)

1

Recupere el ID de empleado, el nombre y el apellido ...
7
Construya una consulta que recupere todas las cuentas abiertas en 2002.


      SELECT *
FROM ACCOUNT
WHERE OPEN_DATE BE...
13
Escriba una consulta compuesta que encuentre el nombre y los apellidos de todos los
clientes, junto con el nombre y los...
17
Escriba una consulta que devuelva sólo el mes de la fecha actual.

USE [EJER_01]
SELECT MONTH (GETDATE ())




        ...
19
8.2
Modifique su consulta del ejercicio 8.1 para que calcule el número de cuentas que
tiene cada cliente. Muestre el ID...
select cust_id
from CUSTOMER
where cust_id <=20
22
9.1
Construya una consulta sobre la tabla account que utiliza una condición de filtrado
con una subconsulta no correlac...
23
Modifique la consulta del ejercicio 9.1 utilizando una subconsulta correlacionada
sobre la tabla product para obtener l...
24
Relacione la siguiente consulta con la tabla employee, para mostrar el nivel de
experiencia de cada empleado:

SELECT '...
25
Construya una consulta sobre la tabla employee que recupere el ID de empleado, el
nombre y el apellido, además del nomb...
TABLAS




BRANCH




ACCOUNT
CUSTOMER




BUSSINESS
EMPLOYEE




DEPARTMENT




TRANSACTION
PRODUCT_TYPE




PRODUCT




OFFICER
INDIVIDUAL




             INSERTANDO DATOS
BRANCH




CUSTOMER
DEPARTMENT




EMPLOYEE
PRODUCT TYPE CD




PRODUCT
ACCOUNT
BUSINESS




INDIVIDUAL
TRANSACCION
OFFICER
Ejercicios De Sql (actualizado)
Ejercicios De Sql (actualizado)
Upcoming SlideShare
Loading in …5
×

Ejercicios De Sql (actualizado)

22,644 views

Published on

Published in: Business, Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Ejercicios De Sql (actualizado)

  1. 1. UNIVERSIDAD VERACRUZANA Facultad de Administración Experiencia: • Base de datos Alumno: • Lara López Karime Arely • Madrigal Sosa Mariel • Zarate Osorio Erik Eduardo Catedrático: • Dr. Carlos Arturo Torres Gastelú Nombre del Trabajo: • Ejercicios de SQL obligatorios y opcionales Veracruz, ver a 14 de Diciembre del 2009
  2. 2. DIAGRAMA BRANCH BRANCH_ID EMPLOYEE NAME EMP_ID DEPARTMENT ADDRESS FNAME DEPT_ID CITY LNAME NAME STATE START_DATE ZIP END_DATE SUPERIOR_EMP_ID DEPT_ID TITLE ASSIGNED_BRANCH_ID PRODUCT_TYPE * PRODUCT_TYPE_CD TRANSACCION * NAME TXN_ID TXN_DATE ACCOUNT_ID TXN_TYPE_CD ACCOUNT * AMOUNT PRODUCT * ACCOUNT_ID TELLER_EMP_ID PRODUCT_CD CUST_ID EXECUTION_BRANCH_ID NAME OPEN_DATE FUNDS_AVAIL_dATE PRODUCT_TYPE_CD CLOSE_DATE DATE_OFFERED LASTE_ACTIVITY_DATE DATE_RETIRED STATUS OPEN_BRANCH_ID OPEN_EMP_ID AVAIL_BALANCE PENDING_BALANCE PRODUCT_CD CUSTOMER * CUST_ID FED_ID CUST_TYPE_CD address city state postal_code OFFICER * OFFICER_ID FNAME INDIVIDUAL * LNAME CUST_ID TITLE BUSINESS * LFNAME START_DATE CUST_ID LNAME END_DATE NAME BIRTH_DATE CUST_ID STATE_ID INCORP_DATE
  3. 3. EJERCICIOS DE SQL (OPCIONALES.) 1 Recupere el ID de empleado, el nombre y el apellido de todos los empleados del banco. Ordene por apellido y nombre. SELECT EMP_ID, FNAME, LNAME FROM EMPLOYEE ORDER BY FNAME, LNAME
  4. 4. 7 Construya una consulta que recupere todas las cuentas abiertas en 2002. SELECT * FROM ACCOUNT WHERE OPEN_DATE BETWEEN '2002-01-01' AND '2002-12-31' 11 Construya una consulta que localice a todos los empleados cuyo supervisor esté asignado a un departamento diferente. Recupere los ID de empleados, el nombre y el primer apellido. SELECT EMP_ID, FNAME, LNAME, DEPT_ID, SUPERIOR_EMP_ID FROM EMPLOYEE WHERE SUPERIOR_EMP_ID <> dep_id Order by emp_id, fname, lname
  5. 5. 13 Escriba una consulta compuesta que encuentre el nombre y los apellidos de todos los clientes, junto con el nombre y los apellidos de todos los empleados. USE EJER_01 SELECT LFNAME,lname FROM individual UNION SELECT fname,lname FROM employee
  6. 6. 17 Escriba una consulta que devuelva sólo el mes de la fecha actual. USE [EJER_01] SELECT MONTH (GETDATE ()) EJERCICIOS DE SQL (OBLIGATORIOS) 18(8.1) Construya una consulta que cuente el número de filas en la tabla de cuentas. SELECT Count(*) AS Total FROM ACCOUNT
  7. 7. 19 8.2 Modifique su consulta del ejercicio 8.1 para que calcule el número de cuentas que tiene cada cliente. Muestre el ID del cliente y el número de cuentas por cada uno. SELECT Count(*) AS Total FROM customer group by cust_id
  8. 8. select cust_id from CUSTOMER where cust_id <=20
  9. 9. 22 9.1 Construya una consulta sobre la tabla account que utiliza una condición de filtrado con una subconsulta no correlacionada sobre la tabla product, para recuperar todas los préstamos (product.product_type_cd = 'LOAN'). Recuperar el ID de cuenta, el código de producto, el ID de cliente y el saldo disponible. select ACCOUNT_ID, PRODUCT_ID, CUST_ID,.PRESTAMO (select count(d.numeroitem) from Detalles as d where f.numero=d.numerofactura) as cantidad, (select sum(d.preciounitario*cantidad) from Detalles as d where f.numero=d.numerofactura) as total from facturas as f;
  10. 10. 23 Modifique la consulta del ejercicio 9.1 utilizando una subconsulta correlacionada sobre la tabla product para obtener los mismos resultados.
  11. 11. 24 Relacione la siguiente consulta con la tabla employee, para mostrar el nivel de experiencia de cada empleado: SELECT 'trainee' name, '2004-01-01' start_dt, '2005-12-31' end_dt UNIONALL SELECT 'worker' name, '2002-01-01' start_dt, '2003-12-31' end_dt UNIONALL SELECT 'mentor' name, '2000-01-01' start_dt, '2001-12-31' end_dt Póngale a la subconsulta el alias "levels"e incluya el ID de empleado, el nombre, el apellido y el nivel de experiencia (Ievels.name). SELECT 'trainee' name, '2007-01-01' start_dt, '2009-12-31' end_dt UNION ALL SELECT 'worker' name, '2004-01-01' start_dt, '2006-12-31' end_dt UNION ALL SELECT 'mentor' name, '2001-01-01' start_dt, '2003-12-31' end_dt from EMPLOYEE
  12. 12. 25 Construya una consulta sobre la tabla employee que recupere el ID de empleado, el nombre y el apellido, además del nombre del departamento y la sucursal a la que está asignado. No relacione (una) ninguna tabla. SELECT emp_id, fname, LNAME, DEPT_ID, ASSIGNED_BRANCH_ID FROM EMPLOYEE
  13. 13. TABLAS BRANCH ACCOUNT
  14. 14. CUSTOMER BUSSINESS
  15. 15. EMPLOYEE DEPARTMENT TRANSACTION
  16. 16. PRODUCT_TYPE PRODUCT OFFICER
  17. 17. INDIVIDUAL INSERTANDO DATOS BRANCH CUSTOMER
  18. 18. DEPARTMENT EMPLOYEE
  19. 19. PRODUCT TYPE CD PRODUCT
  20. 20. ACCOUNT
  21. 21. BUSINESS INDIVIDUAL
  22. 22. TRANSACCION
  23. 23. OFFICER

×