TGViewer
Data Analytics Data Analytics @sqlspecialist · 111K subscribers
Post #2483 7.9K
✅ SQL Functions Interview Questions with Answers 🎯📚

1️⃣ Q: What is the difference between COUNT(*) and COUNT(column_name)?
A:
- COUNT(*) counts all rows, including those with NULLs.
- COUNT(column_name) counts only rows where the column is NOT NULL.

2️⃣ Q: When would you use GROUP BY with aggregate functions?
A:
Use GROUP BY when you want to apply aggregate functions per group (e.g., department-wise total salary):
SELECT department, SUM(salary) FROM employees GROUP BY department;


3️⃣ Q: What does the COALESCE() function do?
A:
COALESCE() returns the first non-null value from the list of arguments.
Example:
SELECT COALESCE(phone, 'N/A') FROM users;


4️⃣ Q: How does the CASE statement work in SQL?
A:
CASE is used for conditional logic inside queries.
Example:
SELECT name,  
CASE
WHEN score >= 90 THEN 'A'
WHEN score >= 75 THEN 'B'
ELSE 'C'
END AS grade
FROM students;


5️⃣ Q: What’s the use of SUBSTRING() function?
A:
It extracts a part of a string.
Example:
SELECT SUBSTRING('DataScience', 1, 4); -- Output: Data


6️⃣ Q: What’s the output of LENGTH('SQL')?
A:
It returns the length of the string: 3

7️⃣ Q: How do you find the number of days between two dates?
A:
Use DATEDIFF(end_date, start_date)
Example:
SELECT DATEDIFF('2026-01-10', '2026-01-05'); -- Output: 5


8️⃣ Q: What does ROUND() do in SQL?
A:
It rounds a number to the specified decimal places.
Example:
SELECT ROUND(3.456, 2); -- Output: 3.46


💡 Pro Tip: Always mention real use cases when answering — it shows practical understanding.

💬 Tap ❤️ for more!
  • ❤ 26
More from @sqlspecialist
  1. Oct 12, 20268️⃣ You receive a dataset with inconsistent date formats. How would you clean it? Sample A…
  2. Oct 12, 2026📊 Data Analyst Interview Series — Part 7 Guys, let's continue our Data Analyst Interview…
  3. Oct 12, 2026🚀 𝗪𝗵𝗶𝗰𝗵 𝗧𝗲𝗰𝗵 𝗦𝗸𝗶𝗹𝗹 𝗪𝗶𝗹𝗹 𝗬𝗼𝘂 𝗠𝗮𝘀𝘁𝗲𝗿 𝗶𝗻 𝟮𝟬𝟮𝟲? Want to buil…
  4. Oct 9, 2026“Here, the data is sorted by the second column in descending order and the first five rows…
  5. Oct 9, 2026📊 Data Analyst Interview Series — Part 6 Guys, let's continue our Data Analyst Interview…
  6. Oct 9, 2026🇮🇳 𝗚𝗢𝗩𝗘𝗥𝗡𝗠𝗘𝗡𝗧 𝗢𝗙 𝗜𝗡𝗗𝗜𝗔 — 𝗔𝗜𝗖𝗧𝗘 𝗜𝗡𝗧𝗘𝗥𝗡𝗦𝗛𝗜𝗣𝗦 𝟮𝟬𝟮𝟲 🚀…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →