Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
i need help
/* CREATE DATABASE `negocios`; USE `negocios`; */ CREATE TABLE clientes ( codigo_cliente int IDENTITY(1,1) PRIMARY KEY, nombre VARCHAR(40), direccion VARCHAR(40), ciudad VARCHAR (40), telefono VARCHAR(40), correo VARCHAR(40)); INSERT INTO clientes (nombre, direccion, ciudad,telefono,correo) VALUES ('almacen_popular', 'las_fuentes_124', 'bilbao','94234-71-27','Camilaper@gmail.com'), ('almacenes_fernandez', 'atocha_55', 'madrid','(912)49-59-73','hourtjuju@hotmail.com'), ('bazar_el_argentino', 'anton_67', 'teruel','(978)56-40-25','juanbravo12@gmail.com'), ('bazar_el_bart', 'diagonal_56', 'barcelona','(936)69-28-66','pablobuit@gmail.com'), ('bazar_francisco', 'carmen_45', 'zamora','(980)49-52-88','Elianea@gmail.com'), ('bazar_la_faraona','castilla_y_leon_34', 'madrid','(915)48-36-27','polvofijo@letito.ku'); /* select * from clientes; */ CREATE TABLE productos ( id_producto INT IDENTITY(1,1) PRIMARY KEY, nombre VARCHAR(40), descripcion VARCHAR(40), precio decimal(5,2), stock INT); INSERT INTO productos(nombre,descripcion,precio,stock) VALUES ('ceramica', 'tubos', '168.43','04'), ('confeccion', 'blusas_sra', '101.05','18'), ('CERAMICA', 'juego_de_te', '43.27','15'), ('deportes', 'balon_futbol', '43.91','04'), ('ceramica', 'jarra_china', '127.77','02'); /* select * from productos; */ CREATE TABLE factura ( numero_factura INT PRIMARY KEY IDENTITY, codigo_cliente INT, total decimal(5,2), forma_de_pago VARCHAR(40), fecha date); INSERT INTO factura (codigo_cliente, total, forma_de_pago,fecha) VALUES ('5', '478.00', 'contado', '2000-06-06'), ('3', '57.00', 'TARJETA', '2000-06-08'), ('4', '80.00', 'aplazado', '2000-07-01'), ('2','155.00', 'contado', '2000-12-12'), ('1','90.00', 'aplazado', '2001-01-01'), ('6', '65.00','tarjeta', '2001-02-04'); /*select * from factura;*/ CREATE TABLE detalle ( id_detalle INT PRIMARY KEY IDENTITY, cantidad int, codigo_articulo INT, descripcion Varchar(40), precio decimal(5,2), total decimal(7,2), num_factura INT,); INSERT INTO detalle ( cantidad, codigo_articulo, descripcion, precio, total, num_factura) VALUES ('27','5', 'jarra_china', '127.77',(27 * 127.77),'4'), ('5','4', 'balon_futbol', '13.50',(5 * 13.50),'4'), ('12','1', 'tubos', '139.99',(12*139.99),'1'), ('24','3', 'juego_de_te', '9.99',(24*9.99),'1'), ('100','2', 'blusas_sra', '15.00',(100*15.00),'2'), ('5','4', 'balon_futbol', '13.50',(5*13.50),'4'); /* select * from detalle; */ /* select fac.numero_factura, fac.total, fac.fecha, cli.nombre from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente); */ /* select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) where cli.codigo_cliente = 5 */ /* select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) where cli.codigo_cliente = 5 */ /* select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) where numero_factura = 5; */ /* select * from factura as fac inner join detalle as det on (fac.numero_factura = det.id_detalle);*/ /* select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) inner join productos as prd on (prd.id_producto = fac.codigo_cliente) where cli.nombre = 'almacen_popular' and numero_factura = 5 order by cli.nombre ASC, cli.direccion DESC; */ /* select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) inner join productos as prd on (prd.id_producto = fac.codigo_cliente) where numero_factura = 2 or numero_factura = 5; */ /* select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) inner join productos as prd on (prd.id_producto = fac.codigo_cliente) where fac.fecha Between '2000-06-08' and '2000-12-12'; */ /* select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) inner join productos as prd on (prd.id_producto = fac.codigo_cliente) where cli.nombre LIKE '%en%'; */ /* Error(s), warning(s): 'CREATE VIEW' must be the first statement in a query batch. CREATE VIEW v_reporte AS SELECT * FROM clientes AS cli INNER JOIN clientes AS cli ON (fac.codigo_cliente = cli.codigo_cliente) INNER JOIN productos AS prd ON (prd.id_producto = fac.codigo_cliente) WHERE cli.nombre LIKE '%en%'; */ /* para evitar el error funciona asi:*/ exec ('CREATE VIEW v_hoja_ruta as select numero_factura, fecha, cantidad, descripcion, nombre, direccion, ciudad, telefono from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) inner join detalle as det on (fac.numero_factura = det.num_factura) where cli.codigo_cliente = fac.codigo_cliente;') /* no acepta el order by order by fac.fecha ASC, cantidad DESC;') */ exec ('CREATE VIEW v_cta_cobro as select numero_factura, fecha, cantidad, descripcion, nombre, det.total from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) inner join detalle as det on (fac.numero_factura = det.num_factura) where cli.codigo_cliente = fac.codigo_cliente;') /* who can help me? */ exec ('CREATE VIEW v_cta_cobro_AF as select * from factura as fac inner join clientes as cli on (fac.codigo_cliente = cli.codigo_cliente) inner join productos as prd on (prd.id_producto = fac.codigo_cliente) where cli.nombre LIKE '%en%';')
run
|
edit
|
history
|
help
0
db3
dbms pracs
lab5
query
shrink logs
mysqltest
ms sql update,insert
Service broker
IOU2
1