You are on page 1of 1

create table Student(roll integer PRIMARY KEY, name varchar(100));

insert into Student(roll, name) values (101, "Ram") ,(102, "Sham") ,(103, "Sita") ,
(104, "Gita") , (105, "Raman") , (106, "Raj");

create table Marks(roll_no integer PRIMARY KEY, maths float, physics float,
chemistry float) ;
insert into Marks(roll_no,maths,physics,chemistry) values (101,95.0,92.0,96.5),
(102,85.0,90.5,78.0),(103,79.0,52.0,46.5),(104,99.5,91.0,92.5),
(105,99.8,84.0,95.0),(106,74.0,90.0,76.0) ;

alter table Marks add average float ;


update Marks set average = (maths+physics+chemistry)/3 ;

select Student.name from Student inner join Marks ON Student.roll = Marks.roll_no


where Marks.maths > 90 and Marks.average > 70;

SELECT roll_no,average from Marks order by average desc limit 2 ;

select Student.name from Student inner join Marks ON Student.roll = Marks.roll_no


where Marks.maths > 90 or Marks.physics > 90 or Marks.chemistry > 90 ;
-- Your code here!

You might also like