Essays.club - Ensayos gratis, notas de cursos, notas de libros, tareas, monografías y trabajos de investigación
Buscar

Transac SQL.

Enviado por   •  11 de Marzo de 2018  •  896 Palabras (4 Páginas)  •  302 Visitas

Página 1 de 4

...

('LONDRES', 8, 'GB'),

('MURCIA', 4, 'SP'),

('TRIPOLI', 2, 'LIB'),

('VICTORIA', 5, 'AUS'),

('BEIJIN', 25, 'CHINA'),

('NV DELHI', 35,'INDIA'),

('FORTALEZA', 30, 'BR'),

('RIO', 12, 'BR'),

('SAN PETESBURGO', 7, 'RUSIA')

/*

A OBTENER:

1.- LISTA DE TODOS LOS PAISES EN CATALOGO PAISES PERO NO EN CATALOGOS CIUDADES

2.- LISTA DE TODAS LAS CIUDADES DE LOS PAISES EN LA TABLA CATALOGOS CIUDADES QUE NO ESTAN EN CAT PAISES

3.- LISTA DE TODOS LOS PAISES QUE ESTAN EN AMBAS TABLAS (SIN REPETICION)

4.- SUMA TOTAL DE TODOS LOS HABITANTES DE LA TABLA CATALOGO PAISES EXCEPTO LA SUMA DE LOS HABITANTES DE LAS CUDADES

5.- LISTA DE TODOS LOS DATOS DE AMBAS TABLAS QUE COINCIDAN EN EL PAIS

*/

--1

SELECT P.Pais

FROM Cat_Paises P

join ciudades on p.CV = ciudades.pais

WHERE p.CV Ciudades.pais

--2

SELECT pais

FROM Ciudades

except( SELECT CV FROM Cat_Paises)

--3

SELECT p.pais

FROM cat_paises p LEFT JOIN

Ciudades c ON p.CV = c.pais

GROUP BY p.pais

--4

SELECT SUM(HabMDH) - (

SELECT sum(c.hab)

FROM Ciudades c join cat_paises p

on p.CV = c.pais) AS Habitantes

FROM Cat_Paises

--5

SELECT *

FROM CIUDADES C

INNER JOIN CAT_PAISES P

ON C.PAIS = P.CV

---------------------------------------------------------------

Evidencia 3° Sesión

--Declaración de variables en Trans SQL

DECLARE @mivariable int,

@otravariable int,

@suma int

SET @mivariable = 5

SET @otravariable = 13

SET @suma = @mivariable + @otravariable

PRINT @suma

--Creación de Data Types

CREATE TYPE MAOG FROM varchar(50)

GO

DECLARE @Nombre MAOG

SET @Nombre = 'Margil Alfonso de Ochoa Garza'

PRINT @Nombre

--TIPOS DE DATOS NUMERICOS

DECLARE @bit bit,

@tinyint tinyint,

@smallint smallint,

@int int,

@bigint bigint,

@decimal decimal(10,3), --10 digitos, 7 enteros y

--3 decimales

@real real,

@double float(53),

@money money

SET @bit = 1

SET @tinyint = 255

SET @smallint = 32767

SET @int = 642325

SET @decimal = 56565.234

SET @money = 12.34

PRINT @tinyint

PRINT @bit

PRINT @smallint

PRINT @int

PRINT @decimal

PRINT @money

---------------------------------------------------------------

Evidencia 4° Sesión

Declare @web varchar(100),

@dim varchar(3)

set @dim = 'DJK'

IF @dim = 'DJK'

begin

print @dim + ' Es verdadero'

End

Else

Begin

print @dim + ' Es Falso'

End

-- -----------------------------------------------------

DECLARE @coPais int,

@descripcion varchar(255)

SET @coPais = 4

SET @descripcion = Null

IF

...

Descargar como  txt (9.4 Kb)   pdf (68.5 Kb)   docx (24 Kb)  
Leer 3 páginas más »
Disponible sólo en Essays.club