MySQL + SQL · Lesson 50
DISTINCT, Alias and ORDER BY
DISTINCT — Unique Rows
SELECT DISTINCT class FROM students;Removes duplicate values from the result.
Alias — Rename in Output
SELECT name AS student_name, marks AS score
FROM students;AS gives a column a friendlier name in the result (does not change the table).
ORDER BY — Sorting
SELECT name, marks FROM students ORDER BY marks DESC;
SELECT name FROM students ORDER BY name ASC;DESC = high to low, ASC = low to high (default).
Summary
- DISTINCT removes duplicates; AS renames output columns.
- ORDER BY sorts: ASC (default) or DESC.
💻 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ें.