-- create a table
CREATE TABLE students (
  stu_id CHAR(6) PRIMARY KEY,
  name VARCHAR(10),
  branch CHAR(4)
);

CREATE TABLE marks (
  stu_id CHAR(6) PRIMARY KEY,
  maths INT(2),
  physics INT(2),
  chemistry INT(2), 
  FOREIGN KEY (stu_id) REFERENCES students(stu_id)
);

-- insert some values
INSERT INTO students VALUES ("MEC001", "Ashwin", "MECH");
INSERT INTO students VALUES ("EEE002", "Babu", "EEE");
INSERT INTO students VALUES ("MEC003", "Daniel", "MECH");

INSERT INTO marks VALUES ("MEC001", 57, 65, 71);
INSERT INTO marks VALUES ("EEE002", 73, 84, 69);
INSERT INTO marks VALUES ("MEC003", 62, 56, 77);

-- fetch some values
SELECT "Min and average";
SELECT MIN(marks.maths), AVG(marks.chemistry)
FROM students, marks
WHERE marks.stu_id = students.stu_id;












Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: