You are on page 1of 25

DBMS LAB with Mini Project(21CSL55) 2023

Program -1
Aim: Demonstrating creation of tables, applying the view concepts on the tables.
Program: Consider the following schema for a Library Database:
BOOK(Book_id, Title, Publisher_Name, Pub_Year)
BOOK_AUTHORS(Book_id, Author_Name)
PUBLISHER(Name, Address, Phone)
BOOK_COPIES(Book_id, Programme_id, No-of_Copies)
BOOK_LENDING(Book_id, Programme_id, Card_No, Date_Out, Due_Date)
LIBRARY_PROGRAMME(Programme_id, Programme_Name, Address)
Write SQL queries to
i. Retrieve details of all books in the library – id, title, name of PUBLISHER, authors,
number of copies in each branch, etc.
ii. Get the particulars of borrowers who have borrowed more than 3 books, but from Jan
2017 to Jun 2017.
iii. Delete a book in BOOK table. Update the contents of other tables to reflect this data
manipulation operation.
iv. Partition the BOOK table based on year of publication. Demonstrate its working with
a simple query.
v. Create a view of all books and its number of copies that are currently available in the
Library.
Schema Diagram:

Yellow = PK

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 1


DBMS LAB with Mini Project(21CSL55) 2023

(i) Query for creating table PUBLISHER:

create table PUBLISHER ( name varchar(12),


address varchar(12), phone int,
primary key(name) );
Output

(ii) Query for creating table BOOK:


create table BOOK ( book_id varchar(5),
title varchar(15), PUBLISHER_name varchar(10),
pub_year int,
primary key(book_id),
foreign key(PUBLISHER_name) references PUBLISHER(name) on delete cascade );
Output

(iii) Query for creating table BOOK_AUTHORS:


create table BOOK_AUTHORS ( book_id varchar(5),
author_name varchar(15),
primary key(book_id),
foreign key(book_id) references Book(book_id) on delete cascade );
Output

(iv) Query for creating table LIBRARY_PROGRMME:


create table LIBRARY_PROGRMME ( programme_id varchar(5),
programme_name varchar(10), address varchar(15),

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 2


DBMS LAB with Mini Project(21CSL55) 2023

primary key(programme_id) );
Output

(v) Query for creating table BOOK_COPIES:


create table BOOK_COPIES ( book_id varchar(5),
Programme_id varchar(5), no_of_copies int,
primary key(book_id,Programme_id),
foreign key(book_id) references book(book_id) on delete cascade,
foreign key(Programme_id) references LIBRARY_PROGRMME(Programme_id) on delete
cascade );
Output

(vi) Query for creating table BOOK_LENDING:


create table BOOK_LENDING (Book_id varchar(5),
Programme_id varchar(5), Card_no varchar(5),
Date_out date, Due_dat e date,
primary key(Book_id,Programme_id,Card_no),
foreign key(Book_id) references BOOK(book_id),
foreign key(Programme_id) references LIBRARY_PROGRMME(Programme_id) on delete
cascade);
Output

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 3


DBMS LAB with Mini Project(21CSL55) 2023

(i)Queries for inserting table PUBLISHER:


insert into PUBLISHER values('Mcgrawhill','Bangalore','9480506312');
insert into PUBLISHER values('Pearson','Newdelhi','9785642365');
insert into PUBLISHER values('Random house','Hydrabad','8796452368');
insert into PUBLISHER values('Sapna','Chenai','8947589632');
insert into PUBLISHER values('Oxford','Bangalore','9785642315');
Output

(ii)Queries for inserting table BOOK:


insert into BOOK values('1','DBMS','Mcgrawhill','2017');
insert into BOOK values('2','ADBMS','Mcgrawhill','2016');
insert into BOOK values('3','CN','Pearson','2016');
insert into BOOK values('4','CG','Oxford','2015');
insert into BOOK values('5','OS','Pearson','2016');
Output

(iii) Queries for inserting table BOOK_AUTHORS:


insert into BOOK_AUTHORS values('1','navathe');
insert into BOOK_AUTHORS values('2','navathe');
insert into BOOK_AUTHORS values('3','tenenboum');
insert into BOOK_AUTHORS values('4','edward');
insert into BOOK_AUTHORS values('5','galvin');

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 4


DBMS LAB with Mini Project(21CSL55) 2023

Output

(iv) Queries for inserting table LIBRARY_PROGRMME:


insert into LIBRARY_PROGRMME values('10','RR nagar','Bangalore');
insert into LIBRARY_PROGRMME values('11','Manipal','Bangalore');
insert into LIBRARY_PROGRMME values('12','RNSIT','Bangalore');
insert into LIBRARY_PROGRMME values('13','Rajajnagar','Bangalore');
insert into LIBRARY_PROGRMME values('14','Nitte','Mangalore');
Output

(v) Queries for inserting table BOOK_COPIES:


insert into BOOK_COPIES values('1','10','10');
insert into BOOK_COPIES values('1','11','5');
insert into BOOK_COPIES values('2','12','2');
insert into BOOK_COPIES values('2','13','5');
insert into BOOK_COPIES values('3','14','7');
insert into BOOK_COPIES values('5','10','1');
insert into BOOK_COPIES values('4','11','3');
Output

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 5


DBMS LAB with Mini Project(21CSL55) 2023

(vi) Queries for inserting table BOOK_LENDING:


insert into BOOK_LENDING values('1','10','101','01-jan-17','01-jun-17');
insert into BOOK_LENDING values('3','14','101','11-jan-17','11-mar-17');
insert into BOOK_LENDING values('2','13','101','21-feb-17','21-apr-17');
insert into BOOK_LENDING values('4','11','101','15-mar-17','15-jul-17');
insert into BOOK_LENDING values('1','11','104','12-apr-17','12-may-17');
Output

(i)Write SQL queries to retrieve details of all books in the library – id, title, name of
PUBLISHER, authors, number of copies in each branch, etc.
Query: select b.book_id, b.title,b.publisher_name,a.author_name,c.no_of_copies,
c.progarmme_id from BOOK b, BOOK_AUTHORS a, BOOK_COPIES c
where b.book_id=a.book_id and b.book_id=c.book_id;
Output

(ii) Write SQL queries to get the particulars of borrowers who have borrowed more than 3
books, but from Jan 2017 to Jun 2017.
Query: select card_no from BOOK_LENDING
where date_out between '01-jan-17' and '30-jun- 17'
group by card_no
having count(*)>3;

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 6


DBMS LAB with Mini Project(21CSL55) 2023

Output

(iii) Write SQL queries to delete a book in BOOK table. Update the contents of other tables
to reflect this data manipulation operation.
Query: delete from BOOK where book_id=3;
Output

SQL> delete from book_authors where book_id=3;


1 row deleted.
SQL> delete from book_copies where book_id=3;
1 row deleted.
SQL> delete from book_lending where book_id=3;
1 row deleted.
SQL> delete from book where book_id=3;
1 row deleted.
(iv) Write SQL queries to partition the BOOK table based on year of publication.
Demonstrate its working with a simple query.
Query: create table bookp( book_id int,
title varchar(15), pub_name varchar(15),
pub_year int, primary key(book_id))
partition by range(pub_year) ( partition p0 values less than(2002),
partition p1 values less than(2010),
partition p2 values less than(2015));
insert into bookp values ('801','dbms','willey','2000');
insert into bookp values ('802','dbms','willey','2009');
insert into bookp values ('803','dbms','willey','2014');

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 7


DBMS LAB with Mini Project(21CSL55) 2023

Output

(v) Write SQL queries to create a view of all books and its number of copies that are
currently available in the Library.
Query: create view no_of_copies as( select book_id,sum(no_of_copies) as copies from
BOOK_COPIES group by book_id);
Output
select *from no_of_copies;

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 8


DBMS LAB with Mini Project(21CSL55) 2023

Program -2
Aim: Discuss the various concepts on constraints and update operations.
Program: Consider the following schema for Order Database:
SALESMAN(Salesman_id, Name, City, Commission)
CUSTOMER(Customer_id, Cust_Name, City, Grade, Salesman_id)
ORDERS(Ord_No, Purchase_Amt, Ord_Date, Customer_id, Salesman_id)

Write SQL queries to


i. Count the customers with grades above Bangalore’s average.
ii. Find the name and numbers of all salesman who had more than one customer.
iii. List all the salesman and indicate those who have and don’t have customers in their
cities (Use UNION operation.)
iv. Create a view that finds the salesman who has the customer with the highest order of a
day.
v. Demonstrate the DELETE operation by removing salesman with id 1000. All his
orders must also be deleted.

Schema Diagram:

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 1


DBMS LAB with Mini Project(21CSL55) 2023

(i) Query for creating table salesman:


create table salesman(
sid varchar(5),
sname varchar(15),
city varchar(15),
commission int,
primary key(sid));
Output

(ii) Query for creating table customer:


create table customer(
cid varchar(5),
cname varchar(15),
city varchar(15),
grade int,
sid varchar(5), primary key(cid),
foreign key(sid) references salesman(sid) on delete cascade);
Output

(iii) Query for creating table orders:


create table orders(
orderno varchar(5), purchase_amt int, ord_date date,
cid varchar(5), sid varchar(5),
primary key(orderno),
foreign key(cid) references customer(cid) on delete cascade,
foreign key(sid) references salesman(sid) on delete cascade);
Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 2
DBMS LAB with Mini Project(21CSL55) 2023

Output

(i)Queries for inserting table salesman:


insert into salesman values('1000','arun','mangalore','15');
insert into salesman values('2000','harsha','bangalore','25');
insert into salesman values('3000','sagar','mysore','20');
insert into salesman values('4000','priya','mangalore','30');
insert into salesman values('5000','divya','delhi','15');
Output

(ii)Queries for inserting table customer:


insert into customer values('10','ravi','bangalore','100','1000');
insert into customer values('12','shwetha','mangalore','300','1000');
insert into customer values('14','shalini','chenai','500','2000');
insert into customer values('16','sushmitha','bangalore','700','2000');
insert into customer values('18','pramya','bangalore','500','3000');
Output

(iii) Queries for inserting table orders:


insert into orders values('60','5000','04-jan-17','10','1000');
Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 3
DBMS LAB with Mini Project(21CSL55) 2023

insert into orders values('62','3000','04-jan-17','10','2000');


insert into orders values('64','4000','01-feb-17','12','2000');
insert into orders values('66','450','24-mar-17','14','3000');
insert into orders values('68','2000','01-feb-17','16','1000');
Output

(i)Write SQL queries to Count the customers with grades above Bangalore’s average.
Query: select count(*) as count from customer where grade >(select avg(grade) from
customer where city ='bangalore');

(ii)Write SQL queries to find the name and numbers of all salesman who had more than one
customer.
Query : select s.sid,sname from salesman s,customer c where s.sid=c.sid group
by(s.sid,sname) having count(*)>1;

(iii)Write SQL queries to List all the salesman and indicate those who have and don’t have
customers in their cities (Use UNION operation.)
Query : (select sname,'exists' as same_city from salesman s, customer c
where s.city=c.city and s.sid=c.sid) union (select sname,'not exists' as same_city from
salesman s, customer c where s.city!=c.city and s.sid=c.sid);

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 4


DBMS LAB with Mini Project(21CSL55) 2023

(iv)Write SQL queries to Create a view that finds the salesman who has the customer with the
highest order of a day.
Query : create view sales as (select s.sid,ord_date,sname from salesman s,orders o
where s.sid = o.sid and purchase_amt in(select max(purchase_amt) from orders
group by ord_date));

(v)Write SQL queries to Demonstrate the DELETE operation by removing salesman with id
1000. All his orders must also be deleted.
Query : delete from salesman where sid=1000;

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 5


DBMS LAB with Mini Project(21CSL55) 2023

Program -3
Aim: Demonstrate the concepts of JOIN operations.
Program: Consider the schema for Movie Database:
ACTOR(Act_id, Act_Name, Act_Gender)
DIRECTOR(Dir_id, Dir_Name, Dir_Phone)
MOVIES(Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)
MOVIE_CAST(Act_id, Mov_id, Role)
RATING(Mov_id, Rev_Stars)
Write SQL queries to
1. List the titles of all movies directed by ‘Hitchcock’.
2. Find the movie names where one or more actors acted in two or more movies.
3. List all actors who acted in a movie before 2000 and also in a movie after 2015(use JOIN
operation).
4. Find the title of movies and number of stars for each movie that has at least one rating and
find the highest number of stars that movie received. Sort the result by movie title.
5. Update rating of all movies directed by ‘Steven Spielberg’ to 5.
Schema Diagram:

(i) Query for creating table actor:


create table actor (
Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 1
DBMS LAB with Mini Project(21CSL55) 2023

act_id int,
act_name varchar(10),
act_gender varchar(5),
primary key(act_id));
Output

(ii) Query for creating table director:


create table director (
dir_id int,
dir_name varchar(20),
dir_phone int,
primary key(dir_id));
Output

(iii) Query for creating table movies:


create table movies(
mov_id int,
mov_title varchar(10), mov_year int,
mov_lang varchar(10), dir_id int,
primary key(mov_id),
foreign key(dir_id) references director(dir_id));
Output

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 2


DBMS LAB with Mini Project(21CSL55) 2023

(iv) Query for creating table moviecast:


create table moviecast(
act_id int,
mov_id int,
role varchar(10),
primary key(act_id, mov_id),
foreign key(act_id) references actor(act_id),
foreign key(mov_id) references movies(mov_id) );
Output

(v) Query for creating table rating:


create table rating(
mov_id int,
rev_stars int,
primary key(mov_id),
foreign key(mov_id) references movies(mov_id));
Output

(i)Queries for inserting table actor:


insert into actor values('301','Anushka','F');
insert into actor values('302','Prabhas','M');
insert into actor values('303','Punith','M');
insert into actor values('304','Jermy','M');
insert into actor values('305','yash','M');
Sample Output

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 3


DBMS LAB with Mini Project(21CSL55) 2023

(ii)Queries for inserting table director:


insert into director values('70','Hitchcock','9487563255');
insert into director values('71','Rajamouli','8948562346');
insert into director values('72','steven spielberg','9823654125');
insert into director values('73','Faran','9786542356');
insert into director values('74','Martin','8974563214');
Sample Output

(iii) Queries for inserting table movies:


insert into movies values('1001','Bahubali-2','2017','telugu','70');
insert into movies values('1002','Singham','2008','hindi','71');
insert into movies values('1003','Golmaal-2','2011','telugu','72');
insert into movies values('1004','Allthebest','2015','hindi','73');
insert into movies values('1005','Akash','2009','kannada','74');
Sample Output

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 4


DBMS LAB with Mini Project(21CSL55) 2023

(iv) Queries for inserting table moviecast:


insert into moviecast values('301','1001','Heroine');
insert into moviecast values('302','1002','Hero');
insert into moviecast values('303','1003','Guest');
insert into moviecast values('304','1004','Hero');
insert into moviecast values('305','1005','Heroine');
Sample Output

(v) Queries for inserting table rating:


insert into rating values('1001','4');
insert into rating values('1002','2');
insert into rating values('1003','5');
insert into rating values('1004','3');
insert into rating values('1005','4');
Sample Output

(i)Write SQL queries to list the titles of all movies directed by ‘Hitchcock’
Query: select mov_title
from movies m, director d
where m.dir_id = d.dir_id and dir_name ='Hitchcock';
(ii)Write SQL queries to find the movie names where one or more actors acted in two or
more movies.
Query: select distinct mov_title from movies m, moviecast mc

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 5


DBMS LAB with Mini Project(21CSL55) 2023

where m.mov_id = mc.mov_id and act_id in


(select act_id from moviecast group by(act_id) having count(*)>=2)
group by(mov_title) having count(*)>=1;
(iii)Write SQL queries to list all actors who acted in a movie before 2000 and also in a movie
after 2015(use JOIN operation).
Query: select act_name
from (( actor a join moviecast mc on
a.act_id=mc.act_id) join movies m
on m.mov_id=mc.mov_id)
where
mov_year<2000 intersect
select act_name
from (( actor a join moviecast mc on
a.act_id=mc.act_id) join movies m
on m.mov_id=mc.mov_id)
where mov_year>2015;
(iv)Write SQL queries to Find the title of movies and number of stars for each movie that has
at least one rating and find the highest number of stars that movie received. Sort the result by
movie title.
Query: select mov_title,max(rev_stars)
from movies m, rating r
where m.mov_id= r.mov_id
group by (mov_title) order by mov_title;
(v)Write SQL queries to update rating of all movies directed by ‘Steven Spielberg’ to 5.
Query: update rating set rev_stars=5
where mov_id in(select m.mov_id from movies m,director d
where m.dir_id = d.dir_id and dir_name='stevenspielberg');

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 6


DBMS LAB with Mini Project(21CSL55) 2023

Program - 4
Aim: Introduce concepts of PLSQL and usage on the table.
Program: Program: Consider the schema for College Database:
STUDENT(USN, SName, Address, Phone, Gender)
SEMSEC(SSID, Sem, Sec)
CLASS(USN, SSID)
COURSE(Subcode, Title, Sem, Credits)
IAMARKS(USN, Subcode, SSID, Test1, Test2, Test3, FinalIA)
Write SQL queries to
i. List all the student details studying in fourth semester ‘C’ section.
ii. Compute the total number of male and female students in each semester and in each
section.
iii. Create a view of Test1 marks of student USN ‘1BI15CS101’ in all Courses.
iv. Calculate the FinalIA (average of best two test marks) and update the corresponding table
for all students.
v. Categorize students based on the following criterion:
If FinalIA = 17 to 20 then CAT = ‘Outstanding’
If FinalIA = 12 to 16 then CAT = ‘Average’
If FinalIA< 12 then CAT = ‘Weak’
Give these details only for 8th semester A, B, and C section students.
Schema Diagram:

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 1


DBMS LAB with Mini Project(21CSL55) 2023

(i) Query for creating table student:


create table student (
usn varchar(10),
sname varchar(15),
address varchar(15),
phone int,
gender varchar(6),
primary key(usn));
Output

(ii) Query for creating table semsec:


create table semsec (
ssid varchar(5),
sem int,
sec varchar(5),
primary key(ssid) );
Output

(iii) Query for creating table class:


create table class (
usn varchar(10),
ssid varchar(5),
primary key(usn),
foreign key(usn) references student(usn) on delete cascade,
foreign key(ssid) references semsec(ssid) on delete cascade );

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 2


DBMS LAB with Mini Project(21CSL55) 2023

Output

(iv) Query for creating table course:


create table course (
subcode varchar(8),
title varchar(15),
sem int,
credits int,
primary key(subcode) );
Output

(v) Query for creating table IAmarks:


create table IAmarks (
usn varchar(10),
subcode varchar(8),
ssid varchar(5),
test1 int,
test2 int,
test3 int,
finalIA int,
primary key(usn,subcode,ssid),
foreign key(usn) references student(usn) on delete cascade,
foreign key(subcode) references course (subcode),
foreign key(ssid) references semsec(ssid) );

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 3


DBMS LAB with Mini Project(21CSL55) 2023

Output

(i)Queries for inserting table STUDENT:


insert into STUDENT values('CS101','Arun','ujire','9481235681','Male');
insert into STUDENT values('CS102','Pramya','Mangalore','8945689532','Female');
insert into STUDENT values('CS103','Ravi','Bangalore','9568742361','Male');
insert into STUDENT values('CS104','Vani','Puttur','8945623145','Female');
insert into STUDENT values('CS105','Akshatha','Bantwal','9845632147','Female');
insert into STUDENT values('CS106','Ranjan','Karwar','9485632158','Male');
Sample Output
Select * from student;
(ii)Queries for inserting table SEMSEC:
insert into SEMSEC values('CS4A','4','A');
insert into SEMSEC values('CS4B','4','B');
insert into SEMSEC values('CS4C','4','C');
insert into SEMSEC values('CS8A','8','A');
insert into SEMSEC values('CS8B','8','B');
insert into SEMSEC values('CS8C','8','C');
Sample Output
Select * from SEMSEC;
(iii) Queries for inserting table CLASS:
insert into CLASS values('CS101','CS8A');
insert into CLASS values('CS102','CS8A');
insert into CLASS values('CS103','CS8B');
insert into CLASS values('CS104','CS8C');
insert into CLASS values('CS105','CS4C');
insert into CLASS values('CS106','CS4C');
Sample Output

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 4


DBMS LAB with Mini Project(21CSL55) 2023

Select * from CLASS;

(iv) Queries for inserting table COURSE:


insert into COURSE values('15CS41','ACA','4','5 ');
insert into COURSE values('15CS42 ','GTE','4','4');
insert into COURSE values('15CS43','C++','4','3');
insert into COURSE values('10CS81','JAVA','8','4');
insert into COURSE values('10CS82','WEB','8','4');
insert into COURSE values('10CS83','IOT','8','5');
Sample Output
Select * from COURSE;
(v) Queries for inserting table IAmarks:
insert into IAmarks values('CS101','10CS81','CS8A','19','20','18','');
insert into IAmarks values('CS102','10CS81','CS8A','16','15','12','');
insert into IAmarks values('CS103','10CS82','CS8B','09','08','12','');
insert into IAmarks values('CS104','10CS83','CS8C','03','05','08','');
insert into IAmarks values('CS105','15CS41','CS4C','10','14','16','');
insert into IAmarks values('CS106','15CS43','CS4C','13','15','20','');
Sample Output
select * from iamarks;
(i)Write SQL queries to list all the student details studying in fourth semester ‘C’ section.
Query: select s.usn,sname,gender,address,phone ,sc.sem,sc.sec from
STUDENT s,SEMSEC sc,CLASS c
where s.usn=c.usn and c.ssid=sc.ssid and sc.sem=8 and sc.sec=’C’;
Output:

(ii)Write SQL queries to compute the total number of male and female students in each
semester and in each section .
Query: select sem,sec,gender,count(*) as count from STUDENT s, SEMSEC sc, CLASS c
where s.usn=c.usn and sc.ssid=c.ssid
group by(sem,sec,gender);
Output:
(iii)Write SQL queries to create a view of Test1 marks of student USN ‘1BI17CS101’ in all
subjects.

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 5


DBMS LAB with Mini Project(21CSL55) 2023

Query: create view test1 as ( select usn,test1,subcode from iamarks where usn=’CS101’ );
select * from test1;
Output:
(iv)Write SQL queries to calculate the FinalIA (average of best two test marks) and update
the corresponding table for all students.
Query(a): create view average_finder1 as (select usn,subcode,greatest(test1,test2,test3) as
highest, case when test1<greatest(test1,test2,test3) and test1>least(test1,test2,test3)
then test1 when test2<greatest(test1,test2,test3) and test2>least(test1,test2,test3)
then test2 else test3 end as second_highest from iamarks );
Output:
select * from average_finder1;
Query(b): update IAMARKS a set finalia = ( select (highest+second_highest)/2 from
average_finder1 where a.usn =usn and a.subcode= subcode);
Output:
select * from iamarks;
(v) Categorize students based on the following criterion:
If FinalIA = 17 to 20 then CAT = ‘Outstanding’
If FinalIA = 12 to 16 then CAT = ‘Average’
If FinalIA< 12 then CAT = ‘Weak’
Give these details only for 8th semester A, B, and C section students.
Query: select s.usn,s.sname,s.address,s.phone,s.gender,
(case when ia.finalia between 17 and 20 then 'outstanding'
when ia.finalia between 12 and 16 then 'average'
else 'weak' end) as CATEGORY
from student s, semsec ss, iamarks ia, course c
where s.usn = ia.usn and ss.ssid = ia.ssid and c.subcode = ia.subcode and c.sem = 8;
Output:

Artificial Intelligence and Data Science Engineering AY: 2023-24 Page 6

You might also like