MySQL + SQL · Lesson 57

COUNT, SUM, AVG, MIN और MAX

COUNT()

SELECT COUNT(*) FROM students;            -- सारी rows
SELECT COUNT(phone) FROM students;       -- non-NULL phones
SELECT COUNT(DISTINCT class) FROM students; -- unique classes

SUM, AVG, MAX, MIN

SELECT SUM(amount) AS total_fee FROM fees;
SELECT AVG(marks) AS avg_marks FROM students;
SELECT MAX(marks) AS topper FROM students;
SELECT MIN(marks) AS lowest FROM students;
AS use करने से summary column को साफ नाम मिलता है।

महत्वपूर्ण

COUNT(*) सारी rows गिनता है NULLs समेत; COUNT(column) उस column के NULLs छोड़ देता है।

सारांश

  • COUNT(*) = सारी rows; COUNT(col) NULLs छोड़ता है; COUNT(DISTINCT col) = unique।
  • SUM/AVG numbers के लिए, MAX/MIN highest/lowest के लिए।
🔗

Share this topic with a friend

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

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

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

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

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