SubConsultas SQL SERVER
Publicado por Osvaldo (13 intervenciones) el 20/04/2021 01:05:13
Saludos a todos. Deseo recibir sus aportes y criticas al siguiente código SQL, trabajo con SQL SERVER e intente realizar una subconsulta. Utilice dos tablas.
VENDEDOR
CodVendedor smallint PK
NombreVendedor varchar(50)
PorcComision real NOT NULL
FACTURA
NroFactira int PK,identity (1,1)
NroCuenta int FK,NOT NULL
CodVendedor smallint FK,NOT NULL
PorComision real NOT NULL
CodAgencia smallint FK,NOT NULL
CodDeposito smallint FK, NOT NULL
CodMoneda smallint FK,NOT NULL
FechaCotizacion datetime NOT NULL
MontoCambio money NOT NULL
FechaEmision datetime
FechaRendicion datetime
Plazo int NOT NULL
PorcDescuento real NOT NULL, Default 0
MontoTotal money
MontoIVA money
MontoNetoIVA money
El siguiente es el enunciado y el código al cual llego.
VENDEDOR
CodVendedor smallint PK
NombreVendedor varchar(50)
PorcComision real NOT NULL
FACTURA
NroFactira int PK,identity (1,1)
NroCuenta int FK,NOT NULL
CodVendedor smallint FK,NOT NULL
PorComision real NOT NULL
CodAgencia smallint FK,NOT NULL
CodDeposito smallint FK, NOT NULL
CodMoneda smallint FK,NOT NULL
FechaCotizacion datetime NOT NULL
MontoCambio money NOT NULL
FechaEmision datetime
FechaRendicion datetime
Plazo int NOT NULL
PorcDescuento real NOT NULL, Default 0
MontoTotal money
MontoIVA money
MontoNetoIVA money
El siguiente es el enunciado y el código al cual llego.
1
2
3
4
5
/*Listar datos de vendedores que hayan realizado ventas superiores a 10.000.000 */
select Vendedor.*
From Vendedor
where codvendedor > (select Factura.Montototal from factura where
factura.Codvendedor = vendedor.codvendedor and montototal = 10000000)
Valora esta pregunta


0