Buy us a coffeeहमें एक coffee पिलाएँ

SQL for Beginners in Hindi: Queries You Need First

Learn the handful of SQL queries that do most of the real work, using one small sales table, with free tools to practise and interview-style questions.

Founder, YUNOVA3 min read

Contentsविषय-सूची
  1. Short answer
  2. The one table we'll use
  3. Where to practise (free)
  4. 1. SELECT – data dekhna
  5. 2. WHERE – filter
  6. 3. ORDER BY – sort
  7. 4. Calculated column
  8. 5. GROUP BY – summary
  9. 6. HAVING – group ke baad filter
  10. 7. JOIN – do tables jodna
  11. Order of a query (why errors happen)
  12. Ten practice questions
  13. Mistakes beginners make
  14. FAQ
  15. Learn it free on YUNOVA

Short answer

SQL database से data निकालने की भाषा है। शुरुआत में आपको बस 6 चीज़ें चाहिए: SELECT, WHERE, ORDER BY, GROUP BY (SUM/COUNT के साथ), HAVING, और JOIN. इन्हीं से analyst का ज़्यादातर रोज़ का काम हो जाता है। एक छोटी table बनाइए और हर query खुद चलाइए।

The one table we'll use

I like teaching SQL with one small table, because the queries make sense when you can picture the data. Call it sales:

idorder_datecityproductqtyprice
12026-10-01JaipurNotebook1045
22026-10-01DelhiPen pack560
32026-10-02JaipurStapler2120
42026-10-03MumbaiNotebook845
52026-10-03DelhiNotebook445

Where to practise (free)

  • SQLite with "DB Browser for SQLite" – easiest on a laptop.
  • PostgreSQL or MySQL – what many companies use.
  • Online SQL playgrounds also work for quick tries.

The basic queries below work the same in all three.

1. SELECT – data dekhna

SELECT * FROM sales;
SELECT city, product, qty FROM sales;

* matlab saare columns. Real kaam mein sirf zaroori columns lijiye.

2. WHERE – filter

SELECT * FROM sales WHERE city = 'Jaipur';
SELECT * FROM sales WHERE qty >= 5 AND product = 'Notebook';

Text ko single quotes mein likhiye.

3. ORDER BY – sort

SELECT * FROM sales ORDER BY qty DESC;

DESC = bade se chhota. Default ASC hai.

4. Calculated column

SELECT product, qty, price, qty * price AS amount FROM sales;

AS se column ko naam dete hain.

5. GROUP BY – summary

Ye wahi kaam hai jo Excel mein pivot table karta hai.

SELECT city, SUM(qty * price) AS revenue
FROM sales
GROUP BY city;

Result: Jaipur 690, Delhi 480, Mumbai 360.

Rule: SELECT mein jo column aggregate (SUM, COUNT...) nahi hai, wo GROUP BY mein hona chahiye.

6. HAVING – group ke baad filter

SELECT city, SUM(qty * price) AS revenue
FROM sales
GROUP BY city
HAVING SUM(qty * price) > 400;

WHERE rows ko filter karta hai, HAVING groups ko. Interview mein ye farq zaroor poochte hain.

7. JOIN – do tables jodna

Maan lijiye ek aur table hai cities:

citystate
JaipurRajasthan
DelhiDelhi
MumbaiMaharashtra
SELECT s.product, s.city, c.state
FROM sales s
JOIN cities c ON s.city = c.city;
JOINKya deta hai
INNER JOINSirf matching rows
LEFT JOINLeft table ki saari rows + match ho to right ka data

Agar Excel mein aapne XLOOKUP use kiya hai, JOIN usi ka bada bhai hai. Compare: VLOOKUP vs XLOOKUP.

Order of a query (why errors happen)

You write: SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY. The database runs roughly: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY.

That's why you can't use a SELECT alias inside WHERE in most databases. It hasn't been created yet.

Ten practice questions

Try these on the table above:

  1. All orders from Delhi.
  2. Total quantity sold per product.
  3. Revenue per day.
  4. The city with the highest revenue.
  5. Orders where qty is between 3 and 8.
  6. Number of orders per city.
  7. Average price per product.
  8. Products sold in more than one city.
  9. Revenue per state (needs JOIN).
  10. Top 2 orders by amount.

If you can do all ten without help, you're ready for the SQL round in most entry-level analyst interviews.

Mistakes beginners make

  1. Forgetting quotes around text.
  2. Using WHERE instead of HAVING after GROUP BY.
  3. JOIN without ON – it multiplies rows.
  4. Running UPDATE or DELETE without WHERE. On real data, that's a very bad day.

FAQ

SQL seekhne ke liye coding aani chahiye?

Nahi. SQL bahut readable hai. Excel aata hai to aur aasaan lagega.

MySQL, PostgreSQL ya SQLite – kaunsa seekhein?

Basics teeno mein same hain. Job posts mein jo zyada dikhe, aage wahi.

Data analyst ke liye kitna SQL chahiye?

SELECT se JOIN tak pakka, phir subqueries, CASE WHEN aur window functions. Full roadmap: how to become a data analyst.

Learn it free on YUNOVA

YUNOVA की SQL & Databases skill में ये सारी queries Hindi और English videos के साथ step-by-step हैं, quizzes और final test के साथ।

Learn SQL free on YUNOVA

Also read: Python kaise sikhe

Sourcesस्रोत

  1. postgresql.org/docs/current/tutorial.html
  2. sqlite.org/lang_select.html
  3. dev.mysql.com/doc/refman/8.0/en/select.html
Shareशेयर करेंWhatsAppLinkedInX

Follow YUNOVA for daily tipsरोज़ के tips के लिए YUNOVA को फ़ॉलो करें

Report this post