Aim:

To explore the set operations and sorting and grouping operation using SQL.

Algorithm:

Step 1: Start the program.

Step 2: Create the Table.

Step 3: Insert the values using DML commands.

Step 4: View the full table.

Step 5: Execute the set operation in the table.

Step 6: Get the output.

Step 7: Stop the program.

Program


create table stud(st_name varchar(15),st_reg varchar(10),st_fee number(10));

insert into stud values('KRISHNAN','17UCM036',18000);
insert into stud values('HARI','17UCC036',16000);
insert into stud values('HARSITH','17UPA036',19000);
insert into stud values('HAREESH','17UCS036',21000);

select * from stud;


create table mark(st_name varchar(15),st_reg varchar(10),st_mark number(5));

insert into mark values('SETHU','17UCA036',400);
insert into mark values('HARI','17UCC036',425);
insert into mark values('HARSITH','17UPA036',475);
insert into mark values('HAREESH','17UCS036',499);
insert into mark values('RAM','17UIT036',399);

select * from mark;


Set operations:

select st_name from stud 
union
select St_name from mark

select st_name from stud 
intersect 
select St_name from mark

Select St_Name from stud 
MINUS
Select St_Name from mark

Select St_Name from stud
 union all
Select St_Name from mark

Group by operations:

select avg(st_mark)
from mark
group by st_reg;


Sort by operations:

SELECT * FROM stud
ORDER BY st_name DESC;


Post a Comment

Previous Post Next Post