SlideShare a Scribd company logo
1 of 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

More Related Content

Recently uploaded

fracturas de antebhbunununrazo [II].pptx
fracturas de antebhbunununrazo  [II].pptxfracturas de antebhbunununrazo  [II].pptx
fracturas de antebhbunununrazo [II].pptxkarlagonzalez159945
 
Teleconferencia Accionistas Q1 2024 . Primer Trimestre-
Teleconferencia Accionistas Q1 2024 . Primer Trimestre-Teleconferencia Accionistas Q1 2024 . Primer Trimestre-
Teleconferencia Accionistas Q1 2024 . Primer Trimestre-ComunicacionesIMSA
 
Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...
Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...
Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...antonellamujica
 
PPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAY
PPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAYPPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAY
PPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAYCarlosAlbertoVillafu3
 
diseño de redes en la cadena de suministro.pptx
diseño de redes en la cadena de suministro.pptxdiseño de redes en la cadena de suministro.pptx
diseño de redes en la cadena de suministro.pptxjuanleivagdf
 
AUDITORIAS en enfermeria hospitalaria .pptx
AUDITORIAS en enfermeria hospitalaria .pptxAUDITORIAS en enfermeria hospitalaria .pptx
AUDITORIAS en enfermeria hospitalaria .pptxMatiasGodoy33
 
CONSTITUCIÓN, CREACION Y GESTION DE EMPRESAS
CONSTITUCIÓN, CREACION Y GESTION DE EMPRESASCONSTITUCIÓN, CREACION Y GESTION DE EMPRESAS
CONSTITUCIÓN, CREACION Y GESTION DE EMPRESASJorgeLuisEspinolaMar
 
IDENTIDAD Y MANUAL DE MARCA PARA BRANDING
IDENTIDAD Y MANUAL DE MARCA PARA BRANDINGIDENTIDAD Y MANUAL DE MARCA PARA BRANDING
IDENTIDAD Y MANUAL DE MARCA PARA BRANDINGAndresGEscobar
 
AFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdf
AFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdfAFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdf
AFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdfOdallizLucanaJalja1
 
DELITOS CONTRA LA GESTION PUBLICA PPT.pdf
DELITOS CONTRA LA GESTION PUBLICA PPT.pdfDELITOS CONTRA LA GESTION PUBLICA PPT.pdf
DELITOS CONTRA LA GESTION PUBLICA PPT.pdfJaquelinRamos6
 
Efectos del cambio climatico en huanuco.pptx
Efectos del cambio climatico en huanuco.pptxEfectos del cambio climatico en huanuco.pptx
Efectos del cambio climatico en huanuco.pptxCONSTRUCTORAEINVERSI3
 
Evaluacion Final de logistica - trabajo final
Evaluacion Final de logistica - trabajo finalEvaluacion Final de logistica - trabajo final
Evaluacion Final de logistica - trabajo finalssuser4a0361
 
Continex para educación, Portafolio de servicios
Continex para educación, Portafolio de serviciosContinex para educación, Portafolio de servicios
Continex para educación, Portafolio de serviciosFundación YOD YOD
 
Presentación La mujer en la Esperanza AC.pptx
Presentación La mujer en la Esperanza AC.pptxPresentación La mujer en la Esperanza AC.pptx
Presentación La mujer en la Esperanza AC.pptxDanielFerreiraDuran1
 
TEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptx
TEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptxTEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptx
TEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptxFrancoSGonzales
 
Trabajo de Sifilisn…………………………………………………..
Trabajo de Sifilisn…………………………………………………..Trabajo de Sifilisn…………………………………………………..
Trabajo de Sifilisn…………………………………………………..JoseRamirez247144
 
ISO 45001-2018.pdf norma internacional para la estandarización
ISO 45001-2018.pdf norma internacional para la estandarizaciónISO 45001-2018.pdf norma internacional para la estandarización
ISO 45001-2018.pdf norma internacional para la estandarizaciónjesuscub33
 
TEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODA
TEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODATEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODA
TEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODACarmeloPrez1
 
LOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESAS
LOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESASLOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESAS
LOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESASemilyacurio2005
 
Modelo de convenio de pago con morosos del condominio (GENÉRICO).docx
Modelo de convenio de pago con morosos del condominio (GENÉRICO).docxModelo de convenio de pago con morosos del condominio (GENÉRICO).docx
Modelo de convenio de pago con morosos del condominio (GENÉRICO).docxedwinrojas836235
 

Recently uploaded (20)

fracturas de antebhbunununrazo [II].pptx
fracturas de antebhbunununrazo  [II].pptxfracturas de antebhbunununrazo  [II].pptx
fracturas de antebhbunununrazo [II].pptx
 
Teleconferencia Accionistas Q1 2024 . Primer Trimestre-
Teleconferencia Accionistas Q1 2024 . Primer Trimestre-Teleconferencia Accionistas Q1 2024 . Primer Trimestre-
Teleconferencia Accionistas Q1 2024 . Primer Trimestre-
 
Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...
Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...
Mapa Conceptual relacionado con la Gerencia Industrial, su ámbito de aplicaci...
 
PPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAY
PPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAYPPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAY
PPT DIAGNOSTICO DAFO Y CAME MEGAPUERTO CHANCAY
 
diseño de redes en la cadena de suministro.pptx
diseño de redes en la cadena de suministro.pptxdiseño de redes en la cadena de suministro.pptx
diseño de redes en la cadena de suministro.pptx
 
AUDITORIAS en enfermeria hospitalaria .pptx
AUDITORIAS en enfermeria hospitalaria .pptxAUDITORIAS en enfermeria hospitalaria .pptx
AUDITORIAS en enfermeria hospitalaria .pptx
 
CONSTITUCIÓN, CREACION Y GESTION DE EMPRESAS
CONSTITUCIÓN, CREACION Y GESTION DE EMPRESASCONSTITUCIÓN, CREACION Y GESTION DE EMPRESAS
CONSTITUCIÓN, CREACION Y GESTION DE EMPRESAS
 
IDENTIDAD Y MANUAL DE MARCA PARA BRANDING
IDENTIDAD Y MANUAL DE MARCA PARA BRANDINGIDENTIDAD Y MANUAL DE MARCA PARA BRANDING
IDENTIDAD Y MANUAL DE MARCA PARA BRANDING
 
AFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdf
AFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdfAFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdf
AFILIACION CAJA NACIONAL DE SALUD WOM 1 .pdf
 
DELITOS CONTRA LA GESTION PUBLICA PPT.pdf
DELITOS CONTRA LA GESTION PUBLICA PPT.pdfDELITOS CONTRA LA GESTION PUBLICA PPT.pdf
DELITOS CONTRA LA GESTION PUBLICA PPT.pdf
 
Efectos del cambio climatico en huanuco.pptx
Efectos del cambio climatico en huanuco.pptxEfectos del cambio climatico en huanuco.pptx
Efectos del cambio climatico en huanuco.pptx
 
Evaluacion Final de logistica - trabajo final
Evaluacion Final de logistica - trabajo finalEvaluacion Final de logistica - trabajo final
Evaluacion Final de logistica - trabajo final
 
Continex para educación, Portafolio de servicios
Continex para educación, Portafolio de serviciosContinex para educación, Portafolio de servicios
Continex para educación, Portafolio de servicios
 
Presentación La mujer en la Esperanza AC.pptx
Presentación La mujer en la Esperanza AC.pptxPresentación La mujer en la Esperanza AC.pptx
Presentación La mujer en la Esperanza AC.pptx
 
TEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptx
TEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptxTEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptx
TEMA 6.- MAXIMIZACION DE LA CONDUCTA DEL PRODUCTOR.pptx
 
Trabajo de Sifilisn…………………………………………………..
Trabajo de Sifilisn…………………………………………………..Trabajo de Sifilisn…………………………………………………..
Trabajo de Sifilisn…………………………………………………..
 
ISO 45001-2018.pdf norma internacional para la estandarización
ISO 45001-2018.pdf norma internacional para la estandarizaciónISO 45001-2018.pdf norma internacional para la estandarización
ISO 45001-2018.pdf norma internacional para la estandarización
 
TEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODA
TEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODATEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODA
TEMA N° 3.2 DISENO DE ESTRATEGIA y ANALISIS FODA
 
LOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESAS
LOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESASLOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESAS
LOS MODELOS DE LA COMUNICACIÓN HUMANA 1° ADM. DE EMPRESAS
 
Modelo de convenio de pago con morosos del condominio (GENÉRICO).docx
Modelo de convenio de pago con morosos del condominio (GENÉRICO).docxModelo de convenio de pago con morosos del condominio (GENÉRICO).docx
Modelo de convenio de pago con morosos del condominio (GENÉRICO).docx
 

Featured

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
 

Featured (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