SlideShare una empresa de Scribd logo
1 de 25
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
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
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
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
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
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
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
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 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;
23
Modifique la consulta del ejercicio 9.1 utilizando una subconsulta correlacionada
sobre la tabla product para obtener los mismos resultados.
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
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
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

Más contenido relacionado

Último

GERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESAS
GERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESASGERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESAS
GERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESASSilvanabelenCumpasip
 
VAMOS MANAOS, análisis e historia de la empresa Manaos
VAMOS MANAOS, análisis e historia de la empresa ManaosVAMOS MANAOS, análisis e historia de la empresa Manaos
VAMOS MANAOS, análisis e historia de la empresa Manaosmalenasilvaet7
 
REINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEA
REINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEAREINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEA
REINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEAElvisLpez14
 
Emprendedores peruanos, empresas innovadoras.pptx
Emprendedores peruanos, empresas innovadoras.pptxEmprendedores peruanos, empresas innovadoras.pptx
Emprendedores peruanos, empresas innovadoras.pptxFERNANDOMIGUELRIVERA1
 
Aprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdf
Aprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdfAprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdf
Aprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdfLizbethMuoz40
 
1 GENERALIDADES Bioestadística y demografia.pdf
1 GENERALIDADES Bioestadística y demografia.pdf1 GENERALIDADES Bioestadística y demografia.pdf
1 GENERALIDADES Bioestadística y demografia.pdfjoanjustiniano98
 
METODO MIXTOpresentaciondeadministracion.pptx
METODO MIXTOpresentaciondeadministracion.pptxMETODO MIXTOpresentaciondeadministracion.pptx
METODO MIXTOpresentaciondeadministracion.pptxBrayanParra38
 
modalidades de importaciones de productos
modalidades de importaciones de productosmodalidades de importaciones de productos
modalidades de importaciones de productosRaynelLpezVelsquez
 
Regímenes laborales en el Perú actualizados al 2024
Regímenes laborales en el Perú actualizados al 2024Regímenes laborales en el Perú actualizados al 2024
Regímenes laborales en el Perú actualizados al 2024fanny vera
 
Libros - Las 48 leyes del Poder vida.pdf
Libros - Las 48 leyes del Poder vida.pdfLibros - Las 48 leyes del Poder vida.pdf
Libros - Las 48 leyes del Poder vida.pdfomd190207
 
Gastos que no forman parte del Valor en Aduana de la mercadería importada
Gastos que no forman parte del Valor en Aduana de la mercadería importadaGastos que no forman parte del Valor en Aduana de la mercadería importada
Gastos que no forman parte del Valor en Aduana de la mercadería importadaInstituto de Capacitacion Aduanera
 
CADENA DE SUMINISTROS DIAPOSITIVASS.pptx
CADENA DE SUMINISTROS DIAPOSITIVASS.pptxCADENA DE SUMINISTROS DIAPOSITIVASS.pptx
CADENA DE SUMINISTROS DIAPOSITIVASS.pptxYesseniaGuzman7
 
LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...
LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...
LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...EmelynYesmynVegaArre
 
INVESTIGACIÓN EN INGENIERIA - El Problema de investigación
INVESTIGACIÓN EN INGENIERIA - El Problema de investigaciónINVESTIGACIÓN EN INGENIERIA - El Problema de investigación
INVESTIGACIÓN EN INGENIERIA - El Problema de investigaciónGabrielaRisco3
 
INTELIGENCIA EMOCIONAL -ADMINISTRACION.pdf
INTELIGENCIA EMOCIONAL -ADMINISTRACION.pdfINTELIGENCIA EMOCIONAL -ADMINISTRACION.pdf
INTELIGENCIA EMOCIONAL -ADMINISTRACION.pdfELISATORRES56
 
Presentacion de politica de descuento pronto pago.pptx
Presentacion de politica de descuento pronto pago.pptxPresentacion de politica de descuento pronto pago.pptx
Presentacion de politica de descuento pronto pago.pptxroberto1981hn
 
Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...
Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...
Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...Oxford Group
 
GUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdf
GUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdfGUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdf
GUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdfRasecGAlavazOllirrac
 
FORMATO ASISTENCIA DE CAPACITACION.doc..
FORMATO ASISTENCIA DE CAPACITACION.doc..FORMATO ASISTENCIA DE CAPACITACION.doc..
FORMATO ASISTENCIA DE CAPACITACION.doc..angelicacardales1
 
Presentación Martin Purisaca - BCP...ppt
Presentación Martin Purisaca - BCP...pptPresentación Martin Purisaca - BCP...ppt
Presentación Martin Purisaca - BCP...pptjoseccampos94
 

Último (20)

GERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESAS
GERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESASGERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESAS
GERENCIA DE OPERACIONES MBA ADMINISTRACION DE EMPRESAS
 
VAMOS MANAOS, análisis e historia de la empresa Manaos
VAMOS MANAOS, análisis e historia de la empresa ManaosVAMOS MANAOS, análisis e historia de la empresa Manaos
VAMOS MANAOS, análisis e historia de la empresa Manaos
 
REINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEA
REINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEAREINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEA
REINGENIERA, GESTION DE ADMINISTRACION CONTEMPORANEA
 
Emprendedores peruanos, empresas innovadoras.pptx
Emprendedores peruanos, empresas innovadoras.pptxEmprendedores peruanos, empresas innovadoras.pptx
Emprendedores peruanos, empresas innovadoras.pptx
 
Aprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdf
Aprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdfAprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdf
Aprendizaje basado en proyectos. La vida no son asignaturas_CPAL_PERU.pdf
 
1 GENERALIDADES Bioestadística y demografia.pdf
1 GENERALIDADES Bioestadística y demografia.pdf1 GENERALIDADES Bioestadística y demografia.pdf
1 GENERALIDADES Bioestadística y demografia.pdf
 
METODO MIXTOpresentaciondeadministracion.pptx
METODO MIXTOpresentaciondeadministracion.pptxMETODO MIXTOpresentaciondeadministracion.pptx
METODO MIXTOpresentaciondeadministracion.pptx
 
modalidades de importaciones de productos
modalidades de importaciones de productosmodalidades de importaciones de productos
modalidades de importaciones de productos
 
Regímenes laborales en el Perú actualizados al 2024
Regímenes laborales en el Perú actualizados al 2024Regímenes laborales en el Perú actualizados al 2024
Regímenes laborales en el Perú actualizados al 2024
 
Libros - Las 48 leyes del Poder vida.pdf
Libros - Las 48 leyes del Poder vida.pdfLibros - Las 48 leyes del Poder vida.pdf
Libros - Las 48 leyes del Poder vida.pdf
 
Gastos que no forman parte del Valor en Aduana de la mercadería importada
Gastos que no forman parte del Valor en Aduana de la mercadería importadaGastos que no forman parte del Valor en Aduana de la mercadería importada
Gastos que no forman parte del Valor en Aduana de la mercadería importada
 
CADENA DE SUMINISTROS DIAPOSITIVASS.pptx
CADENA DE SUMINISTROS DIAPOSITIVASS.pptxCADENA DE SUMINISTROS DIAPOSITIVASS.pptx
CADENA DE SUMINISTROS DIAPOSITIVASS.pptx
 
LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...
LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...
LOS BANCOS EN PERÚ establece las normas para la contabilización de los invent...
 
INVESTIGACIÓN EN INGENIERIA - El Problema de investigación
INVESTIGACIÓN EN INGENIERIA - El Problema de investigaciónINVESTIGACIÓN EN INGENIERIA - El Problema de investigación
INVESTIGACIÓN EN INGENIERIA - El Problema de investigación
 
INTELIGENCIA EMOCIONAL -ADMINISTRACION.pdf
INTELIGENCIA EMOCIONAL -ADMINISTRACION.pdfINTELIGENCIA EMOCIONAL -ADMINISTRACION.pdf
INTELIGENCIA EMOCIONAL -ADMINISTRACION.pdf
 
Presentacion de politica de descuento pronto pago.pptx
Presentacion de politica de descuento pronto pago.pptxPresentacion de politica de descuento pronto pago.pptx
Presentacion de politica de descuento pronto pago.pptx
 
Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...
Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...
Evaluación y Mejora Continua Guía de Seguimiento y Monitoreo para Cursos de C...
 
GUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdf
GUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdfGUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdf
GUIA DE ESTUDIOS DESARROLLO DE HABILIDADES DIRECTIVAS.pdf
 
FORMATO ASISTENCIA DE CAPACITACION.doc..
FORMATO ASISTENCIA DE CAPACITACION.doc..FORMATO ASISTENCIA DE CAPACITACION.doc..
FORMATO ASISTENCIA DE CAPACITACION.doc..
 
Presentación Martin Purisaca - BCP...ppt
Presentación Martin Purisaca - BCP...pptPresentación Martin Purisaca - BCP...ppt
Presentación Martin Purisaca - BCP...ppt
 

Destacado

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 HubspotMarius Sescu
 
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 ChatGPTExpeed Software
 
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 EngineeringsPixeldarts
 
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 HealthThinkNow
 
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.pdfmarketingartwork
 
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 2024Neil Kimberley
 
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)contently
 
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 2024Albert Qian
 
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 InsightsKurio // The Social Media Age(ncy)
 
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 2024Search Engine Journal
 
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 summarySpeakerHub
 
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 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 Tessa Mero
 
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 IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
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 managementMindGenius
 
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...RachelPearson36
 

Destacado (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...
 

Ejercicios de SQL obligatorios y opcionales de la Facultad de Administración de la Universidad Veracruzana

  • 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. 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. 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. 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. 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. 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. 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
  • 9.
  • 10. 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;
  • 11. 23 Modifique la consulta del ejercicio 9.1 utilizando una subconsulta correlacionada sobre la tabla product para obtener los mismos resultados.
  • 12. 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
  • 13. 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
  • 14.
  • 19. INDIVIDUAL INSERTANDO DATOS BRANCH CUSTOMER