Descargue como DOCX, PDF, TXT o lea en línea desde Scribd
Descargar como docx, pdf o txt
Está en la página 1de 8
QUERY SISTEMA DE VENTAS
CREATE DATABASE BDVENTA
USE BDVENTA
--Configurando formato de fecha
SET DATEFORMAT DMY
--Creación de tabla DISTRITO
CREATE TABLE DISTRITO( COD_DIS CHAR(5) NOT NULL PRIMARY KEY, NOM_DIS VARCHAR(50) NOT NULL )
--Creación de tabla VENDEDOR
CREATE TABLE VENDEDOR( COD_VEN CHAR(3) NOT NULL PRIMARY KEY , NOM_VEN VARCHAR(20) NOT NULL, APE_VEN VARCHAR(20) NOT NULL, SUE_VEN MONEY NOT NULL, FIN_VEN DATE NOT NULL, TIP_VEN VARCHAR(10) NOT NULL, COD_DIS CHAR(5) NOT NULL REFERENCES DISTRITO )
CREATE TABLE CLIENTE(
COD_CLI CHAR(5) NOT NULL PRIMARY KEY, RSO_CLI CHAR(30) NOT NULL, DIR_CLI VARCHAR(100)NOT NULL, TLF_CLI CHAR(9) NOT NULL, RUC_CLI CHAR(11) NULL, COD_DIS CHAR(5) NOT NULL REFERENCES DISTRITO, FEC_REG DATE NOT NULL, TIP_CLI VARCHAR(10) NOT NULL, CON_CLI VARCHAR(30) NOT NULL )
CREATE TABLE PROVEEDOR(
COD_PRV CHAR(5) NOT NULL PRIMARY KEY, RSO_PRV VARCHAR(80) NOT NULL, DIR_PRV VARCHAR(100)NOT NULL, TEL_PRV CHAR(15) NULL, COD_DIS CHAR(5) NOT NULL REFERENCES DISTRITO, REP_PRV VARCHAR(80) NOT NULL )
CREATE TABLE FACTURA(
NUM_FAC VARCHAR(12) NOT NULL PRIMARY KEY, FEC_FAC DATE NOT NULL, COD_CLI CHAR(5) NOT NULL REFERENCES CLIENTE, FEC_CAN DATE NOT NULL, EST_FAC VARCHAR(10) NOT NULL, COD_VEN CHAR(3) NOT NULL REFERENCES VENDEDOR, POR_IGV DECIMAL NOT NULL ) CREATE TABLE ORDEN_COMPRA( NUM_OCO CHAR(5) NOT NULL PRIMARY KEY, FEC_OCO DATE NOT NULL, COD_PRV CHAR(5) NOT NULL REFERENCES PROVEEDOR, FAT_OCO DATE NOT NULL, EST_OCO CHAR(1) NOT NULL )
CREATE TABLE PRODUCTO(
COD_PRO CHAR(5) NOT NULL PRIMARY KEY, DES_PRO VARCHAR(50) NOT NULL, PRE_PRO MONEY NOT NULL, SAC_PRO INT NOT NULL, SMI_PRO INT NOT NULL, UNI_PRO VARCHAR(30) NOT NULL, LIN_PRO VARCHAR(30) NOT NULL, IMP_PRO VARCHAR(10) NOT NULL )
CREATE TABLE DETALLE_FACTURA(
NUM_FAC VARCHAR(12) NOT NULL REFERENCES FACTURA, COD_PRO CHAR(5) NOT NULL REFERENCES PRODUCTO, CAN_VEN INT NOT NULL, PRE_VEN MONEY NOT NULL PRIMARY KEY (NUM_FAC,COD_PRO) )
CREATE TABLE DETALLE_COMPRA(
NUM_OCO CHAR(5) NOT NULL REFERENCES ORDEN_COMPRA, COD_PRO CHAR(5) NOT NULL REFERENCES PRODUCTO, CAN_DET INT NOT NULL PRIMARY KEY (NUM_OCO,COD_PRO) )
CREATE TABLE ABASTECIMIENTO(
COD_PRV CHAR(5) NOT NULL REFERENCES PROVEEDOR, COD_PRO CHAR(5) NOT NULL REFERENCES PRODUCTO, PRE_ABA MONEY NOT NULL PRIMARY KEY (COD_PRV,COD_PRO) )
INSERT INTO DISTRITO VALUES('D01','SURCO')
INSERT INTO DISTRITO VALUES('D02','JESUS MARIA') INSERT INTO DISTRITO VALUES('D03','SAN ISIDRO') INSERT INTO DISTRITO VALUES('D04','LA MOLINA') INSERT INTO DISTRITO VALUES('D05','SAN MIGUEL') INSERT INTO DISTRITO VALUES('D06','MIRAFLORES') INSERT INTO DISTRITO VALUES('D07','BARRANCO') INSERT INTO DISTRITO VALUES('D08','CHORRILLOS') INSERT INTO DISTRITO VALUES('D09','SAN BORJA') INSERT INTO DISTRITO VALUES('D10','LINCE') INSERT INTO DISTRITO VALUES('D11','BREÑA') INSERT INTO DISTRITO VALUES('D12','MAGDALENA') INSERT INTO DISTRITO VALUES('D13','RIMAC') INSERT INTO DISTRITO VALUES('D14','SURQUILLO') INSERT INTO DISTRITO VALUES('D15','PUEBLO LIBRE') INSERT INTO DISTRITO VALUES('D16','BELLAVISTA') INSERT INTO DISTRITO VALUES('D17','CALLAO') INSERT INTO DISTRITO VALUES('D18','SAN MARTIN DE PORRES') INSERT INTO DISTRITO VALUES('D19','SANTA ANITA') INSERT INTO DISTRITO VALUES('D20','LOS OLIVOS') INSERT INTO DISTRITO VALUES('D21','INDEPENDENCIA') INSERT INTO DISTRITO VALUES('D22','LIMA - CERCADO') INSERT INTO DISTRITO VALUES('D24','SAN LUIS') INSERT INTO DISTRITO VALUES('D25','EL AGUSTINO') INSERT INTO DISTRITO VALUES('D26','SAN JUAN DE LURIGANCHO') INSERT INTO DISTRITO VALUES('D27','ATE - VITARTE') INSERT INTO DISTRITO VALUES('D28','SAN JUAN DE MIRAFLORES') INSERT INTO DISTRITO VALUES('D29','CARMEN DE LA LEGUA') INSERT INTO DISTRITO VALUES('D30','COMAS') INSERT INTO DISTRITO VALUES('D31','VILLA MARIA DEL TRIUNFO') INSERT INTO DISTRITO VALUES('D32','VILLA EL SALVADOR') INSERT INTO DISTRITO VALUES('D33','LA PERLA') INSERT INTO DISTRITO VALUES('D34','VENTANILLA') INSERT INTO DISTRITO VALUES('D35','PUENTE PIEDRA') INSERT INTO DISTRITO VALUES('D36','CARABAYLLO') INSERT INTO DISTRITO VALUES('D37','SANTA MARIA')
INSERT INTO VENDEDOR VALUES('V01','JUANA','ALVA',1000,'07/12/2003','1','D08')
INSERT INTO VENDEDOR VALUES('V02','JUAN','SOTO',1200,'10/03/2002','2','D03') INSERT INTO VENDEDOR VALUES('V03','CARLOS','AREVALO',1500,'02/10/1992','2','D09') INSERT INTO VENDEDOR VALUES('V04','CESAR','OJEDA',850,'08/11/1999','1','D01') INSERT INTO VENDEDOR VALUES('V05','JULIO','VEGA',1500,'11/05/1997','1','D01') INSERT INTO VENDEDOR VALUES('V06','ANA','ORTEGA',1200,'11/05/1994','1','D05') INSERT INTO VENDEDOR VALUES('V07','JOSE','PALACIOS',2500,'12/02/1997','1','D02') INSERT INTO VENDEDOR VALUES('V08','RUBEN','GOMEZ',1450,'12/08/1996','2','D04') INSERT INTO VENDEDOR VALUES('V09','PATRICIA','ARCE',1800,'12/05/1997','2','D04') INSERT INTO VENDEDOR VALUES('V10','RENATO','PEREZ',1550,'11/08/1998','2','D01')
INSERT INTO CLIENTE VALUES('C001','FINSETH','AV. LOS VIÑEDOS
150','4342318','48632081','D05','12/10/2008','1','ALICIA BARRETO') INSERT INTO CLIENTE VALUES('C002','ORBI','AV. EMILIO CAVENECIA 225','4406335','57031642','D04','02/01/2013','2','ALFONSO BELTRAN') INSERT INTO CLIENTE VALUES('C003','SERVIEMSA','JR. COLLAGATE 522','75012403',NULL,'D05','06/03/2011','2','CHRISTIAN LAGUNA') INSERT INTO CLIENTE VALUES('C004','ISSA','CALLE LOS AVIADORES 263','3725910','46720159','D01','9/12/2012','1','LUIS APUMAYTA') INSERT INTO CLIENTE VALUES('C005','MASS','AV. TOMAS MARSANO 880','4446177','83175942','D14','10/01/2013','1','KATIA ARMEJO') INSERT INTO CLIENTE VALUES('C006','BERKER','AV. LOS PROCERES 521','3810322','54890124','D05','7/05/2013','1','JUDITH ASTE') INSERT INTO CLIENTE VALUES('C007','FIDENZA','JR. EL NIQUEL 282','5289034','16204790','D20','10/02/2012','2','HECTOR VIVANCO') INSERT INTO CLIENTE VALUES('C008','INTECH','AV. SAN LUIS 2619 5TO P','2249493','34021824','D09','01/07/2011','2','CARLOS VILLANUEVA') INSERT INTO CLIENTE VALUES('C009','PROMINENT','JR. IQUIQUE 132','43233519',NULL,'D11','06/11/2010','1','JORGE VALDIVIA') INSERT INTO CLIENTE VALUES('C010','LANDU','AV.NICOLAS DE AYLLON 1453','3267840','30405261','D05','11/06/2013','2','RAQUEL ESPINOZA') INSERT INTO CLIENTE VALUES('C011','FILASUR','AV. EL SANTUARIO 1189','4598175','70345201','D26','08/04/2012','1','ANGELICA VIVAS') INSERT INTO CLIENTE VALUES('C012','SUCERTE','JR. GRITO DE HUAURA 114','4206434','62014503','D05','11/08/2011','1','KARINA VEGA') INSERT INTO CLIENTE VALUES('C013','HAYASHI','JR. AYACUCHO 359','42847990',NULL,'D22','03/09/2013','2','ERNESTO UEHARA') INSERT INTO CLIENTE VALUES('C014','KADIA','AV.SANTA CRUZ 1332 OF.201','4412418','22202915','D06','10/05/2011','1','MIGUEL ARCE') INSERT INTO CLIENTE VALUES('C015','MEBA','AV. ELMER FAUCETT 1638',' 4641234','50319542','D16','06/11/2011','2','RICARDO GOMEZ') INSERT INTO CLIENTE VALUES('C016','CARDELI','JR. BARTOLOME HERRERA 451','2658853','26403158','D10','5/04/2013','2','GIANCARLO BONIFAZ') INSERT INTO CLIENTE VALUES('C017','PAYET','CALLE JUAN FANNING 327',' 4779834','70594032','D07','5/12/2013','1','PAOLA URIBE') INSERT INTO CLIENTE VALUES('C018','DASIN','AV. SAENZ PEÑA 338 - B',' 4657574','35016752','D17','12/03/2011','1','ANGELA BARRETO') INSERT INTO CLIENTE VALUES('C019','COREFO','AV. CANADA 3894 - 3898','4377499','57201691','D24','01/03/2010','2','ROSALYN CORTEZ') INSERT INTO CLIENTE VALUES('C020','CRAMER','JR. MARISCAL MILLER 1131','4719061','46031783','D02','8/11/2010','1','CHRISTOPHER RAMOS')
INSERT INTO PROVEEDOR VALUES('PR01','FABER CASTELL','AV. ISABEL LA CATOLICA
1875','4330895','D13','CARLOS AGUIRRE') INSERT INTO PROVEEDOR VALUES('PR02','ATLAS','AV. LIMA 471','5380926','D13','CESAR TORRES') INSERT INTO PROVEEDOR VALUES('PR03','3M','AV. VENEZUELA 3018','2908165','D16','OMAR INJOQUE') INSERT INTO PROVEEDOR VALUES('PR04','DITO','AV. METROPOLITANA 376',NULL,'D19','RAMON FLORES') INSERT INTO PROVEEDOR VALUES('PR05','ACKER','CALLE LAS DUNAS 245','4780143','D27','JULIO ACUÑA') INSERT INTO PROVEEDOR VALUES('PR06','DEDITEC','CALLE PICHINCHA 644','5662848','D11','JAVIER GONZALES') INSERT INTO PROVEEDOR VALUES('PR07','OFFICETEC','CALLE LAS PERDICES 225 OF. 204','4216184','D03','CARLOS ROBLES') INSERT INTO PROVEEDOR VALUES('PR08','INVICTA','AV. LOS FRUTALES 564','4364247','D27','ALBERTO RODRIGUEZ') INSERT INTO PROVEEDOR VALUES('PR09','DIPROPOR','AV. DEL AIRE 901','4742046','D24','ROBERTO RONCEROS') INSERT INTO PROVEEDOR VALUES('PR10','MIURA','AV. LA PAZ 257','4459710','D06','JORGE VASQUEZ') INSERT INTO PROVEEDOR VALUES('PR11','PRAXIS','AV. JOSE GALVEZ 1820 - 1844','4703944','D10','ERICKA ZEGARRA') INSERT INTO PROVEEDOR VALUES('PR12','SUMIGRAF','AV. MANCO CAPAC 754','3320343','D13','KARINNA PAREDES') INSERT INTO PROVEEDOR VALUES('PR13','LIMMSA','PROLG. HUAYLAS 670','2546995','D08','LAURA ORTEGA') INSERT INTO PROVEEDOR VALUES('PR14','VENINSA','AV. TEJADA 338','2473832','D07','MELISA RAMOS') INSERT INTO PROVEEDOR VALUES('PR15','CROSLAND','AV. ARGENTINA 3206 - 3250','4515272','D17','JUAN RAMIREZ') INSERT INTO PROVEEDOR VALUES('PR16','PETRAMAS','CALLE JOAQUIN MADRID 141 2DO P',NULL,'D09','ROCIO GUERRERO') INSERT INTO PROVEEDOR VALUES('PR17','REAWSE','AV. SANTA ROSA 480 ',NULL,'D19','MARIA PEREZ') INSERT INTO PROVEEDOR VALUES('PR18','EDUSA','AV. MORALES DUAREZ 1260','4525536','D29','PABLO MARTEL') INSERT INTO PROVEEDOR VALUES('PR19','OTTMER','URB.PRO INDUSTRIAL MZ B6 LT 16','5369893','D18','ANGELA RENDILLA') INSERT INTO PROVEEDOR VALUES('PR20','BARI','AV. ARNALDO MARQUEZ 1219',NULL,'D02','VANESA QUINTANA')
INSERT INTO FACTURA VALUES('FA001','06-07-2013','C001','05-08-
2013','2','V01','0.19') INSERT INTO FACTURA VALUES('FA002','06-07-2013','C019','05-08- 2013','3','V02','0.19') INSERT INTO FACTURA VALUES('FA003','01-09-2013','C003','03-10- 2013','2','V04','0.19') INSERT INTO FACTURA VALUES('FA004','06-09-2013','C016','05-10- 2013','2','V07','0.19') INSERT INTO FACTURA VALUES('FA005','01-10-2013','C015','12-10- 2013','2','V08','0.19') INSERT INTO FACTURA VALUES('FA006','01-08-2013','C009','05-08- 2013','3','V05','0.19') INSERT INTO FACTURA VALUES('FA007','05-10-2013','C019','10-10- 2013','1','V09','0.19') INSERT INTO FACTURA VALUES('FA008','04-10-2013','C012','06-10- 2013','2','V10','0.19') INSERT INTO FACTURA VALUES('FA009','03-10-2013','C008','10-10- 2013','2','V09','0.19') INSERT INTO FACTURA VALUES('FA010','01-10-2013','C017','06-10- 2013','2','V02','0.19') INSERT INTO FACTURA VALUES('FA011','10-09-2013','C019','10-09- 2013','2','V05','0.19') INSERT INTO FACTURA VALUES('FA012','01-12-2013','C014','01-12- 2013','1','V04','0.19') INSERT INTO FACTURA VALUES('FA013','01-12-2013','C011','01-12- 2013','3','V08','0.19') INSERT INTO FACTURA VALUES('FA014','01-12-2012','C020','01-12- 2013','2','V09','0.19') INSERT INTO FACTURA VALUES('FA015','08-12-2012','C015','06-01- 2013','2','V07','0.19') INSERT INTO FACTURA VALUES('FA016','06-01-2013','C016','09-01- 2013','2','V05','0.19') INSERT INTO FACTURA VALUES('FA017','06-01-2013','C015','06-01- 2013','1','V06','0.19') INSERT INTO FACTURA VALUES('FA018','03-02-2013','C016','04-02- 2013','2','V10','0.19') INSERT INTO FACTURA VALUES('FA019','07-02-2013','C008','01-03- 2013','2','V03','0.19') INSERT INTO FACTURA VALUES('FA020','06-02-2013','C013','10-03- 2013','2','V02','0.19')
INSERT INTO ORDEN_COMPRA VALUES('OC001','05-03-2013','PR08',' 12-03-2013','1')
INSERT INTO ORDEN_COMPRA VALUES('OC002','08-04-2013','PR16',' 10-04-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC003','02-08-2013','PR10' ,'02-08-2013', '3') INSERT INTO ORDEN_COMPRA VALUES('OC004','05-04-2013','PR01','5-04-2013', '3') INSERT INTO ORDEN_COMPRA VALUES('OC005','06-03-2013','PR07',' 10-03-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC006','02-01-2013','PR19',' 2-01-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC007','06-02-2013','PR20' ,'5-04-2013', '3') INSERT INTO ORDEN_COMPRA VALUES('OC008','02-06-2013','PR04',' 01-07-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC009','03-08-2013','PR11',' 10-09-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC010','05-09-2013','PR01',' 5-09-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC011','02-10-2013','PR03',' 3-10-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC012','04-10-2013','PR14' ,'5-10-2013','3') INSERT INTO ORDEN_COMPRA VALUES('OC013','02-11-2013','PR05','6-11-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC014','03-11-2013','PR19',' 5-12-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC015','03-11-2013','PR18',' 10-12-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC016','06-12-2013','PR06' ,'06-12-2013', '3') INSERT INTO ORDEN_COMPRA VALUES('OC017','08-01-2013','PR09',' 8-01-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC018','01-02-2013','PR20',' 8-02-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC019','03-03-2013','PR11',' 6-03-2013','1') INSERT INTO ORDEN_COMPRA VALUES('OC020','02-04-2013','PR05' ,'2-04-2013','2')
INSERT INTO PRODUCTO VALUES('P001','PAPEL BOND A-4',35.0,
200,1500,'MLL','2','V') INSERT INTO PRODUCTO VALUES('P002','PAPEL BOND OFICIO ',35, 50,1500,'MLL','2','F') INSERT INTO PRODUCTO VALUES('P003','PAPEL BULKY ',10 ,498,1000,'MLL','2','V') INSERT INTO PRODUCTO VALUES('P004','PAPEL PERIODICO',9,4285,1000,'MLL','2','F') INSERT INTO PRODUCTO VALUES('P005','CARTUCHO TINTA NEGRA', 40 ,50,30,'UNI','1','F') INSERT INTO PRODUCTO VALUES('P006','CARTUCHO TINTA COLOR ',45 ,58,35, 'UNI','1','F') INSERT INTO PRODUCTO VALUES('P007','PORTA DISKETTES',3.5,300,100,'UNI','1','V') INSERT INTO PRODUCTO VALUES('P008','CAJA DE DISKETTES * 10 ',30,125,180,'UNI','1','F') INSERT INTO PRODUCTO VALUES('P009','BORRADOR DE TINTA ',10 ,100,500,'DOC','3','F') INSERT INTO PRODUCTO VALUES('P010','BORRADOR BLANCO ',8 ,2000,400,'DOC','3','F') INSERT INTO PRODUCTO VALUES('P011','TAJADOR METAL ',20 ,1120,300,'DOC','3','F') INSERT INTO PRODUCTO VALUES('P012','TAJADOR PLASTICO',12 ,608,300,'DOC','3','F') INSERT INTO PRODUCTO VALUES('P013','FOLDER MANILA OFICIO',20,200,150,'CIE','3','F') INSERT INTO PRODUCTO VALUES('P014','FOLDER MANILA A-4',20 ,150,150,'CIE','3','V') INSERT INTO PRODUCTO VALUES('P015','SOBRE MANILA OFICIO',15,300,130,'CIE','3','F') INSERT INTO PRODUCTO VALUES('P016','SOBRE MANILA A-4',18,200,100,'CIE','3','F') INSERT INTO PRODUCTO VALUES('P017','LAPICERO NEGRO',10,3000,1000,'DOC','3','F') INSERT INTO PRODUCTO VALUES('P018','LAPICERO AZUL ',10 ,2013,1500,'DOC','3','F') INSERT INTO PRODUCTO VALUES('P019','LAPICERO ROJO',8,1900,1000,'DOC','3','V') INSERT INTO PRODUCTO VALUES('P020','FOLDER PLASTICO A-4',50 ,3080,1100,'CIE','3','F') INSERT INTO PRODUCTO VALUES('P021','PROTECTOR DE PANTALLA',50,20,5,'UNI','1','F')
INSERT INTO DETALLE_FACTURA VALUES('FA001','P007','6' ,'5')
INSERT INTO DETALLE_FACTURA VALUES('FA001','P011','25' ,'25') INSERT INTO DETALLE_FACTURA VALUES('FA001','P013','11' ,'20') INSERT INTO DETALLE_FACTURA VALUES('FA002','P004','8' ,'10') INSERT INTO DETALLE_FACTURA VALUES('FA003','P002','10' ,'40') INSERT INTO DETALLE_FACTURA VALUES('FA003','P011','6' ,'20') INSERT INTO DETALLE_FACTURA VALUES('FA003','P017','21' ,'12') INSERT INTO DETALLE_FACTURA VALUES('FA003','P019','12' ,'10') INSERT INTO DETALLE_FACTURA VALUES('FA004','P004','3' ,'10') INSERT INTO DETALLE_FACTURA VALUES('FA004','P009','50' ,'5') INSERT INTO DETALLE_FACTURA VALUES('FA005','P003','20' ,'10') INSERT INTO DETALLE_FACTURA VALUES('FA005','P006','50' ,'50') INSERT INTO DETALLE_FACTURA VALUES('FA005','P020','5' ,'60') INSERT INTO DETALLE_FACTURA VALUES('FA006','P002','20' ,'35') INSERT INTO DETALLE_FACTURA VALUES('FA006','P003','15' ,'10') INSERT INTO DETALLE_FACTURA VALUES('FA006','P009','12' ,'5') INSERT INTO DETALLE_FACTURA VALUES('FA007','P003','20' ,'12') INSERT INTO DETALLE_FACTURA VALUES('FA007','P012','4' ,'12') INSERT INTO DETALLE_FACTURA VALUES('FA008','P004','15' ,'9') INSERT INTO DETALLE_FACTURA VALUES('FA008','P008','15' ,'30') INSERT INTO DETALLE_FACTURA VALUES('FA008','P020','50' ,'50') INSERT INTO DETALLE_FACTURA VALUES('FA009','P001','5' ,'30') INSERT INTO DETALLE_FACTURA VALUES('FA009','P002','15' ,'35') INSERT INTO DETALLE_FACTURA VALUES('FA009','P006','2' ,'50') INSERT INTO DETALLE_FACTURA VALUES('FA009','P019','1' ,'8') INSERT INTO DETALLE_FACTURA VALUES('FA010','P002','3' ,'35') INSERT INTO DETALLE_FACTURA VALUES('FA011','P002','20' ,'35') INSERT INTO DETALLE_FACTURA VALUES('FA012','P002','3' ,'35') INSERT INTO DETALLE_FACTURA VALUES('FA012','P006','1' ,'50') INSERT INTO DETALLE_FACTURA VALUES('FA013','P002','130' ,'35') INSERT INTO DETALLE_FACTURA VALUES('FA013','P003','5' ,'12') INSERT INTO DETALLE_FACTURA VALUES('FA013','P015','4' ,'12') INSERT INTO DETALLE_FACTURA VALUES('FA014','P009','10' ,'8') INSERT INTO DETALLE_FACTURA VALUES('FA015','P008','5' ,'30') INSERT INTO DETALLE_FACTURA VALUES('FA015','P016','3' ,'18') INSERT INTO DETALLE_FACTURA VALUES('FA016','P006','15' ,'50') INSERT INTO DETALLE_FACTURA VALUES('FA016','P008','2' ,'30') INSERT INTO DETALLE_FACTURA VALUES('FA017','P002','120' ,'40') INSERT INTO DETALLE_FACTURA VALUES('FA017','P005','120' ,'40') INSERT INTO DETALLE_FACTURA VALUES('FA018','P003','4' ,'12') INSERT INTO DETALLE_FACTURA VALUES('FA018','P005','6' ,'40') INSERT INTO DETALLE_FACTURA VALUES('FA019','P002','150' ,'40') INSERT INTO DETALLE_FACTURA VALUES('FA019','P003','6' ,'10') INSERT INTO DETALLE_FACTURA VALUES('FA019','P006','2' ,'45') INSERT INTO DETALLE_FACTURA VALUES('FA019','P008','10' ,'30') INSERT INTO DETALLE_FACTURA VALUES('FA020','P009','120' ,'10') INSERT INTO DETALLE_FACTURA VALUES('FA020','P015','5' ,'15')
INSERT INTO DETALLE_COMPRA VALUES('OC001','P006','100')
INSERT INTO DETALLE_COMPRA VALUES('OC001','P016','20') INSERT INTO DETALLE_COMPRA VALUES('OC002','P003','200') INSERT INTO DETALLE_COMPRA VALUES('OC002','P005','500') INSERT INTO DETALLE_COMPRA VALUES('OC003','P005','50') INSERT INTO DETALLE_COMPRA VALUES('OC004','P009','10') INSERT INTO DETALLE_COMPRA VALUES('OC004','P013','50') INSERT INTO DETALLE_COMPRA VALUES('OC005','P007','150') INSERT INTO DETALLE_COMPRA VALUES('OC005','P008','100') INSERT INTO DETALLE_COMPRA VALUES('OC008','P002','10') INSERT INTO DETALLE_COMPRA VALUES('OC008','P012','100') INSERT INTO DETALLE_COMPRA VALUES('OC009','P009','50') INSERT INTO DETALLE_COMPRA VALUES('OC009','P011','50') INSERT INTO DETALLE_COMPRA VALUES('OC010','P001','100') INSERT INTO DETALLE_COMPRA VALUES('OC011','P008','5') INSERT INTO DETALLE_COMPRA VALUES('OC011','P016','10') INSERT INTO DETALLE_COMPRA VALUES('OC012','P007','50') INSERT INTO DETALLE_COMPRA VALUES('OC012','P011','100') INSERT INTO DETALLE_COMPRA VALUES('OC013','P013','50') INSERT INTO DETALLE_COMPRA VALUES('OC014','P004','50') INSERT INTO DETALLE_COMPRA VALUES('OC014','P008','50') INSERT INTO DETALLE_COMPRA VALUES('OC014','P020','50') INSERT INTO DETALLE_COMPRA VALUES('OC016','P015','100') INSERT INTO DETALLE_COMPRA VALUES('OC017','P012','100') INSERT INTO DETALLE_COMPRA VALUES('OC017','P014','100') INSERT INTO DETALLE_COMPRA VALUES('OC019','P006','100') INSERT INTO DETALLE_COMPRA VALUES('OC020','P005','500') INSERT INTO DETALLE_COMPRA VALUES('OC020','P011','100')
INSERT INTO ABASTECIMIENTO VALUES('PR01','P003','8')
INSERT INTO ABASTECIMIENTO VALUES('PR01','P005','35') INSERT INTO ABASTECIMIENTO VALUES('PR01','P007','3') INSERT INTO ABASTECIMIENTO VALUES('PR01','P009','8') INSERT INTO ABASTECIMIENTO VALUES('PR01','P011','18') INSERT INTO ABASTECIMIENTO VALUES('PR02','P002','30') INSERT INTO ABASTECIMIENTO VALUES('PR02','P007','3') INSERT INTO ABASTECIMIENTO VALUES('PR03','P002','32') INSERT INTO ABASTECIMIENTO VALUES('PR03','P004','7') INSERT INTO ABASTECIMIENTO VALUES('PR04','P001','28') INSERT INTO ABASTECIMIENTO VALUES('PR04','P006','40') INSERT INTO ABASTECIMIENTO VALUES('PR05','P018','9') INSERT INTO ABASTECIMIENTO VALUES('PR06','P009','7') INSERT INTO ABASTECIMIENTO VALUES('PR06','P017','8') INSERT INTO ABASTECIMIENTO VALUES('PR07','P016','15') INSERT INTO ABASTECIMIENTO VALUES('PR07','P019','7') INSERT INTO ABASTECIMIENTO VALUES('PR08','P006','42') INSERT INTO ABASTECIMIENTO VALUES('PR08','P010','6') INSERT INTO ABASTECIMIENTO VALUES('PR09','P002','30') INSERT INTO ABASTECIMIENTO VALUES('PR09','P014','17') INSERT INTO ABASTECIMIENTO VALUES('PR11','P001','27') INSERT INTO ABASTECIMIENTO VALUES('PR11','P006','44') INSERT INTO ABASTECIMIENTO VALUES('PR12','P002','33') INSERT INTO ABASTECIMIENTO VALUES('PR12','P010','7') INSERT INTO ABASTECIMIENTO VALUES('PR13','P005','35') INSERT INTO ABASTECIMIENTO VALUES('PR14','P016','15') INSERT INTO ABASTECIMIENTO VALUES('PR15','P020','45') INSERT INTO ABASTECIMIENTO VALUES('PR16','P008','25') INSERT INTO ABASTECIMIENTO VALUES('PR16','P012','9') INSERT INTO ABASTECIMIENTO VALUES('PR16','P013','15') INSERT INTO ABASTECIMIENTO VALUES('PR19','P008','28') INSERT INTO ABASTECIMIENTO VALUES('PR19','P016','16') INSERT INTO ABASTECIMIENTO VALUES('PR20','P012','10') INSERT INTO ABASTECIMIENTO VALUES('PR20','P020','43')
SELECT * FROM CLIENTE
SELECT * FROM PROVEEDOR SELECT * FROM FACTURA SELECT * FROM ORDEN_COMPRA SELECT * FROM PRODUCTO SELECT * FROM DETALLE_FACTURA SELECT * FROM DETALLE_COMPRA SELECT * FROM VENDEDOR SELECT * FROM DISTRITO SELECT * FROM ABASTECIMIENTO
--- Relacionando 04 tablas con INNER JOIN
SELECT P.DES_PRO, C.CON_CLI FROM DETALLE_FACTURA AS D INNER JOIN PRODUCTO AS P ON P.COD_PRO=D.COD_PRO INNER JOIN FACTURA AS F ON F.NUM_FAC=D.NUM_FAC INNER JOIN CLIENTE AS C ON C.COD_CLI=F.COD_CLI