dear i want to get the last status of the student. If the student has enroll on April and struck/leave in December. then fee table shows (april,may,june,july,august,september,october,november) status (PRESENT) and when he leaves the status shows (N-PRESENT).
please view the attached file and test case.
Test Case
create table student (
stuid number(5) primary key,status varchar2(30),name varchar2(40),class varchar2(40),
doa date,leav_date date,coment varchar2(40));
create table fees (
stuid number(5) references student(stuid),sno number(4),fdate date,fmonth varchar2(20),tmonth varchar2(20),adm number(5),regist number(4),ftution number(4),
other number(4),arrear number(5),tot number(4),paid number(5),bal number(5),fstat varchar2(20));
insert into student (stuid,status,name,class,doa)
values
(1,'PRESENT','ABC','ONE','02-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(2,'PRESENT','BC','ONE','02-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(3,'PRESENT','AC','ONE','02-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(4,'PRESENT','C','PG','03-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(5,'PRESENT','B','PREP','03-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(6,'PRESENT','DD','ONE','04-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(7,'PRESENT','AA','PG','04-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(8,'PRESENT','SBC','NURSERY','03-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(9,'PRESENT','SC','ONE','03-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(10,'PRESENT','SAAC','NURSERY','04-JUN-20');
insert into student (stuid,status,name,class,doa)
values
(11,'PRESENT','SDC','ONE','04-JUN-20');
UPDATE STUDENT SET STATUS='N_PRESENT',LEAV_DATE='15-APR-21'
WHERE STUID IN (1,5,9);
UPDATE STUDENT SET STATUS='N_PRESENT',LEAV_DATE='1-JUN-21'
WHERE STUID IN (10,3);
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,1,'03-JUN-20','JUNE','JUNE',100,100,500,0,0,700,500,200,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,2,'04-JUL-20','JULY','JULY',0,0,500,0,200,700,700,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,3,'04-AUG-20','AUGUST','AUGUST',0,0,500,0,0,500,500,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,4,'04-AUG-20','SEPTEMBER','SEPTEMBER',0,0,500,0,0,500,500,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,5,'06-OCT-20','OCTOBER','OCTOBER',0,0,500,0,0,500,500,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,6,'01-NOV-20','NOVEMBER','NOVEMBER',0,0,500,0,0,500,500,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,7,'16-DEC-20','DECEMBER','DECEMBER',0,0,500,0,0,500,0,0,'N_RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,8,'01-JAN-21','JANUARY','JANUARY',0,0,500,0,500,1000,1000,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,1,'06-JUN-20','JUNE','JUNE',100,100,500,0,0,700,500,200,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,2,'02-JUL-20','JULY','JULY',0,0,500,0,200,700,700,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,3,'01-AUG-20','AUGUST','AUGUST',0,0,800,0,0,800,800,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,4,'03-AUG-20','SEPTEMBER','SEPTEMBER',0,0,800,0,0,800,800,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,5,'04-OCT-20','OCTOBER','OCTOBER',0,0,800,0,0,800,800,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,6,'11-NOV-20','NOVEMBER','NOVEMBER',0,0,800,0,0,800,800,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,7,'16-DEC-20','DECEMBER','DECEMBER',0,0,800,0,0,800,800,0,'RECEIVED');
INSERT INTO FEES (stuid,sno,fdate,fmonth,tmonth,adm,regist,ftution,other,arrear,tot,paid,bal,fstat)
VALUES
(1,8,'11-JAN-21','JANUARY','JANUARY',0,0,800,0,0,800,800,0,'RECEIVED');
-
Attachment: 1.jpg
(Size: 154.52KB, Downloaded 1724 times)
[Updated on: Thu, 01 July 2021 08:18] Report message to a moderator
|