Вы находитесь на странице: 1из 1

CREATE TABLE C_Credito

(NroCred integer not null,


RutCli varchar(9) not null,
FechaOtorg date not null,
Capital integer not null,
Tasa float(4) not null,
Interes integer not null,
Monto integer not null,
Plazo integer not null,
FechaTermino date not null,
Saldo integer not null,
Estado char(9)
)

Alter table C_Credito
ADD CONSTRAINT PK_CREDITO PRIMARY KEY(NroCred)

CREATE TABLE C_Amortizacion
(NroCred Integer not null,
NroCuota Integer not null,
AmortizCuota integer not null,
InteresCuota integer not null,
MontoCuota integer not null,
FechaVenc date not null,
SaldoCuota integer not null,
EstadoCuota char(9) not null,
FechaPago date)

Alter table C_Amortizacion
ADD CONSTRAINT PK_AMORTIZACION PRIMARY KEY(NroCuota)
Alter table C_Amortizacion
ADD CONSTRAINT FK_Credito_Amortizacion
FOREIGN KEY(NroCred)
REFERENCES C_Credito(NroCred)
CREATE INDEX IN_C_Credito_RutCli ON C_Credito(RutCli ASC)
CREATE SEQUENCE CorrelCred
START WITH 2014002
INCREMENT BY 1
MINVALUE 2014002
ORDER
INSERT INTO C_CREDITO
VALUES (CorrelCred.NEXTVAL,'168861115','30-04-2014',100000,1.51,10000,11000000,6
,'30-10-2014',10000,'moroso')
select * from c_credito
CREATE VIEW CuotasMora
AS SELECT nrocuota, amortizcuota, interescuota, montocuota, fechavenc
FROM C_Credito C join C_Amortizacion A on c.nrocred=a.nrocred
where estado='moroso' and tasa < 1.50 and monto>10000000
group by nrocuota, amortizcuota, interescuota, montocuota, fechavenc

select * from cuotasmora

Вам также может понравиться