MySQL + SQL · Lesson 64
Fee Summary Query Using SQL
Goal
Produce a fee summary: how much each student has paid, and who still owes money.
The Query
SELECT s.name,
IFNULL(SUM(f.amount), 0) AS total_paid
FROM students s
LEFT JOIN fees f ON s.roll_no = f.roll_no
GROUP BY s.name
ORDER BY total_paid DESC;LEFT JOIN keeps students who paid nothing; IFNULL shows their total as 0.
Summary
- LEFT JOIN + GROUP BY + SUM builds a per-student fee summary.
- IFNULL turns missing totals into 0 so every student appears.
💻 Live Code Editor
Is page ki language (MYSQL) mein code likhein aur turant chalाएं — yahीं, bina kuch install kiye.Powered by OneCompiler. Agar editor na khule to yahान naye tab mein kholein.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.