MySQL + SQL · Lesson 120

Student Marksheet Database Project

परिचय

Marksheet database students, subjects और उनके marks रखता है, फिर result reports बनाता है।

Schema

CREATE TABLE students (roll_no INT PRIMARY KEY, name VARCHAR(50));
CREATE TABLE marks (roll_no INT, subject VARCHAR(20), score INT,
  PRIMARY KEY(roll_no, subject),
  FOREIGN KEY(roll_no) REFERENCES students(roll_no));

Result Query

SELECT s.name, SUM(m.score) AS total, ROUND(AVG(m.score),1) AS pct
FROM students s JOIN marks m ON s.roll_no=m.roll_no
GROUP BY s.name;

सारांश

  • marks composite key (roll_no + subject) use करता है।
  • JOIN + GROUP BY हर student का total और percentage बनाता है।
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.