La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

Direcciones SELECT Nombre, Apellido, Ciudad FROM Direcciones; Query SELECT * FROM Direcciones.

Presentaciones similares


Presentación del tema: "Direcciones SELECT Nombre, Apellido, Ciudad FROM Direcciones; Query SELECT * FROM Direcciones."— Transcripción de la presentación:

1 Direcciones SELECT Nombre, Apellido, Ciudad FROM Direcciones; Query SELECT * FROM Direcciones

2 Query Sueldos SELECT Nombre FROM Sueldos WHERE Salarios >= 12000

3 Query SELECT Nombre FROM Sueldos WHERE Cargo = CONTADOR SELECT Nombre, Apellido FROM Sueldos WHERE Cargo = CONTADOR AND Salario > 13000

4 Query Condiciones. OR AND NOT LIKE

5 Query SELECT Nombre, Apellido, Salario FROM Sueldos WHERE Apellido LIKE M%;

6 Query Joins Propietario Piezas SELECT Nombre, Apellido FROM Propietario, Piezas WHERE Idendueño = Numdueño AND Articulo= TV

7 Query SELECT SUM(Salarios), AVG(Salarios) FROM Sueldos; SELECT MIN(Salarios) FROM Sueldos WHERE Cargo = Contador;

8 QueryPedidos

9 Query Pediclien

10 Query Productos

11 Query Creando Nuevas Tablas CREATE TABLE ORDENES (IDENTIF INTEGER NOT NULL, DESCRIPCION CHAR(25) NOT NULL CHAR(X) Una columna de Caracteres donde X es el Numero de caracteres permitidos. INTEGER Una columna con un grupo de numeros positivos o negativos.

12 Query DATE Una columna de Fecha LOGICAL Una columna que puede almacenar valores entre Verdadero o Falso. NOT NULL Indica que la columna debe teber un valor. DECIMAL(X, Y) Columna de numeros decimales donde X es el entero y Y los decimales permitidos.

13 Query Alterando las Tablas. ALTER TABLE ORDENES ADD ( PRECIO DECIMAL(8,2) NULL); Adicionando Datos a la Tabla INSERT INTO ORDENES VALUES ( 001, CARGA,125.25); INSERT INTO ORDENES (IDENTIF, DESCRIPCION, PRECIO) VALUES (001, CARGA, )

14 QUERY Borrando Datos. DELETE FROM ORDENES WHERE DESCRIPCION=CARGA DELETE FROM ORDENES WHERE DESCRIPCION=CARGA AND PRECIO <> , Actualizando Datos. UPDATE ORDENES SET PRECIO = WHERE DECRIPCION = CARGA

15 Query GROUP BY y HAVING SELECT COMPRADOR, MAX(PRECIO) FROM VENTAS GROUP BY COMPRADOR; SELECT COMPRADOR, MAX(PRECIO) FROM VENTAS GROUP BY COMPRADOR HAVING PRICE > 12500;

16 Query Otros Ejemplos: SELECT COMPRADOR FROM VENTAS WHERE PRECIO > (SELECT AVG(PRECIO) FROM VENTAS);

17 Query EXISTS y ALL SELECT NOMBRE, APELLIDO FROM CLIENTES WHERE EXISTS (SELECT *FROM COMPRAS WHERE DESCRIPCION = TV; SELECT COMPRADOR FROM VENTAS WHERE PRECIO >= ALL (SELECT PRECIO FROM VENTAS);

18 Query

19

20 SELECT [Nombre de compañía], [Ciudad] FROM [Proveedores] WHERE País = "Brasil" UNION SELECT [Nombre de compañía], [Ciudad] FROM [Clientes] WHERE País = "Brasil"; Query UNION

21 Query

22

23

24

25 IN SELECT FROM WHERE POSICION IN (JEFE, DIRECTOR); BETWEEN SELECT FROM WHERE SALARIO BETWEEN 3000 AND 5000;

26 J1 W X A 11 B 12 C 13 J2 Y Z A 21 C 22 D 23 SELECT * FROM J1 INNER JOIN J2 ON W=Y W X Y Z A 11 A 21 C 13 C 22

27 SELECT * FROM J1 LEFT OUTER JOIN J2 ON W=Y W X Y Z A 11 A 21 B C 13 C 22 SELECT * FROM J1 RIGHT OUTER JOIN J2 ON W=Y W X Y Z A 11 A 21 C 13 C D 23 SELECT * FROM J1 FULL OUTER JOIN J2 ON W=Y W X Y Z A 11 A 21 C 13 C D 23 B

28 SELECT * FROM `detalle` LEFT JOIN ventas ON detalle.`pedido`=ventas.`pedido` WHERE ventas.`pedido` > 11074

29 SELECT detalle.* FROM `detalle` LEFT JOIN ventas ON detalle.`pedido`=ventas.`pedido` WHERE ventas.`pedido` > 11074

30 SELECT * FROM detalle LEFT JOIN productos ON productos.`codigo` = `detalle`.`producto` where detalle.`producto` > 74

31 SELECT * FROM detalle RIGHT JOIN productos ON productos.`codigo` = `detalle`.`producto` where detalle.`producto` > 74

32

33

34

35 SELECT WEEK(SALES_DATE) AS WEEK, DAYOFWEEK(SALES_DATE) AS DAY_WEEK, SALES_PERSON, SUM(SALES) AS UNITS_SOLD FROM SALES WHERE WEEK(SALES_DATE) = 13 GROUP BY WEEK(SALES_DATE), DAYOFWEEK(SALES_DATE), SALES_PERSON ORDER BY WEEK, DAY_WEEK, SALES_PERSON WEEK DAY_WEEK SALES_PERSON UNITS_SOLD 13 6 GOUNOT LEE LUCCHESSI GOUNOT LEE LUCCHESSI 4

36 SELECT WEEK(fentrega) AS semana, DAYOFWEEK(fentrega) AS dia, vendedor, SUM(totalbs) AS ventas_Bs FROM `ventas` WHERE WEEK(fentrega) = 13 GROUP BY WEEK(fentrega), DAYOFWEEK(fentrega), vendedor ORDER BY semana, dia, vendedor

37 SELECT WEEK(SALES_DATE) AS WEEK, DAYOFWEEK(SALES_DATE) AS DAY_WEEK, SALES_PERSON, SALES AS UNITS_SOLD FROM SALES WHERE WEEK(SALES_DATE) = 13 GROUP BY WEEK DAY_WEEK SALES_PERSON UNITS_SOLD 13 6 LUCCHESSI LUCCHESSI LEE LEE LEE GOUNOT GOUNOT GOUNOT LUCCHESSI LUCCHESSI LUCCHESSI LEE LEE LEE LEE GOUNOT GOUNOT GOUNOT 1

38 SELECT WEEK(fentrega) AS semana, DAYOFWEEK(fentrega) AS dia, vendedor, totalbs AS ventas_Bs FROM `ventas` WHERE WEEK(fentrega) = 13 GROUP BY WEEK(fentrega), DAYOFWEEK(fentrega),vendedor,totalbs

39 SELECT WEEK(SALES_DATE) AS WEEK, DAYOFWEEK(SALES_DATE) AS DAY_WEEK, SALES_PERSON, SUM(SALES) AS UNITS_SOLD FROM SALES WHERE WEEK(SALES_DATE) = 13 GROUP BY GROUPING SETS ( (WEEK(SALES_DATE), SALES_PERSON), (DAYOFWEEK(SALES_DATE), SALES_PERSON)) ORDER BY WEEK, DAY_WEEK, SALES_PERSON This results in: WEEK DAY_WEEK SALES_PERSON UNITS_SOLD GOUNOT LEE LUCCHESSI GOUNOT LEE LUCCHESSI GOUNOT LEE LUCCHESSI 4

40 SELECT WEEK(fentrega) AS semana, SUM(totalbs) AS ventas_Bs FROM `ventas` WHERE WEEK(fentrega) = 13 GROUP BY WEEK(fentrega) WITH ROLLUP

41 SELECT WEEK(fentrega) AS semana, DAYOFWEEK(fentrega) AS dia, vendedor, SUM(totalbs) AS ventas_Bs FROM `ventas` WHERE WEEK(fentrega) = 13 GROUP BY WEEK(fentrega), DAYOFWEEK(fentrega), vendedor WITH ROLLUP limit 15

42

43 SELECT WEEK(SALES_DATE) AS WEEK, DAYOFWEEK(SALES_DATE) AS DAY_WEEK, SALES_PERSON, SUM(SALES) AS UNITS_SOLD FROM SALES WHERE WEEK(SALES_DATE) = 13 GROUP BY ROLLUP ( WEEK(SALES_DATE), DAYOFWEEK(SALES_DATE), SALES_PERSON ) ORDER BY WEEK, DAY_WEEK, SALES_PERSON This results in: WEEK DAY_WEEK SALES_PERSON UNITS_SOLD 13 6 GOUNOT LEE LUCCHESSI GOUNOT LEE LUCCHESSI

44 SELECT SALES_PERSON, MONTH(SALES_DATE) AS MONTH, SUM(SALES) AS UNITS_SOLD FROM SALES GROUP BY GROUPING SETS ( (SALES_PERSON, MONTH(SALES_DATE)), ( ) ) ORDER BY SALES_PERSON, MONTH This results in: SALES_PERSON MONTH UNITS_SOLD GOUNOT 3 35 GOUNOT 4 14 GOUNOT 12 1 LEE 3 60 LEE 4 25 LEE 12 6 LUCCHESSI 3 9 LUCCHESSI 4 4 LUCCHESSI

45 SELECT ventas.pais, sum(totalbs) AS total FROM ventas WHERE (totalbs > ) GROUP BY ventas.pais LIMIT 6


Descargar ppt "Direcciones SELECT Nombre, Apellido, Ciudad FROM Direcciones; Query SELECT * FROM Direcciones."

Presentaciones similares


Anuncios Google