MySQL + SQL · Lesson 50

DISTINCT, Alias और ORDER BY

DISTINCT — Unique Rows

SELECT DISTINCT class FROM students;

Result से duplicate values हटाता है।

Alias — Output में Rename

SELECT name AS student_name, marks AS score
FROM students;

AS result में column को आसान नाम देता है (table नहीं बदलता)।

ORDER BY — Sorting

SELECT name, marks FROM students ORDER BY marks DESC;
SELECT name FROM students ORDER BY name ASC;
DESC = ऊँचे से नीचे, ASC = नीचे से ऊँचे (default)।

सारांश

  • DISTINCT duplicates हटाता है; AS output columns rename करता है।
  • ORDER BY sort करता है: ASC (default) या DESC।
🔗

Share this topic with a friend

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

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

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

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

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