Skip to content

Instantly share code, notes, and snippets.

@theabhayprajapati
Last active September 7, 2022 19:38
Show Gist options
  • Save theabhayprajapati/24a8a751be243b3905bd426d069b8574 to your computer and use it in GitHub Desktop.
Save theabhayprajapati/24a8a751be243b3905bd426d069b8574 to your computer and use it in GitHub Desktop.
create table student(rno int(5) primary key, name varchar(10) not null, address varchar(30), phone varchar(10));
create table marks(rno int(5), maths int(3), cs int(3), phy int(3), bio int(5), chem int(5));
insert into student values (1, "Abhay", "Bengaluru", "1000000000"), (2,"Arin","Hyderabad", "2000000000"), (3,"Om", "Pune", "3000000000"),(4, "Asha", "Mumbai", "5000000000"), (5, "Kapil", "Delhi", "5000000000");
insert into marks values (1, 234, 432,354, 456, 343), (2,453,655,654,765,134), (3, 382,891,329,839,177),(4,928,314,533,242,659),(5,392,432,565,732,676);
select s.rno "Roll Number", name "Name", SUM(maths+cs+phy+bio+chem) "Total Marks" from student s inner join marks m on s.rno=m.rno group by s.rno;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment