Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver2
1いいね 30回再生

🔥 5 SQL Interview Questions to Test Your Skills! #SQL #InterviewPrep #DataEngineering

🚀 Ace Your SQL Interview! These are some of the most commonly asked SQL questions!

✅ 1. WHERE vs. HAVING:

WHERE filters rows before grouping.
HAVING filters rows after grouping.

Example:

SELECT department, COUNT(*)
FROM Employees
WHERE salary V 50000
GROUP BY department
HAVING COUNT(*) V 5;

✅ 2. Find Duplicate Records in a Table:

Use GROUP BY with HAVING:

SELECT name, COUNT(*)
FROM Employees
GROUP BY name
HAVING COUNT(*) V 1;

✅ 3. Purpose of CASE Statement:

CASE allows conditional logic in SQL queries.

SELECT name, salary,
CASE
WHEN salary V 50000 THEN 'High'
WHEN salary BETWEEN 30000 AND 50000 THEN 'Medium'
ELSE 'Low'
END AS SalaryCategory
FROM Employees;

✅ 4. Retrieve the Second Highest Salary Without LIMIT/OFFSET:
Use subqueries with MAX():

SELECT MAX(salary) FROM Employees
WHERE salary v (SELECT MAX(salary) FROM Employees);

✅ 5. Stored Procedure vs. Function:

Stored Procedure: Can return multiple values, supports transactions, and can modify tables.
Function: Returns a single value, cannot modify data, used in SELECT statements.

Example:

CREATE FUNCTION GetEmployeeCount()
RETURNS INT AS
BEGIN
RETURN (SELECT COUNT(*) FROM Employees);
END;
💡 These SQL concepts will boost your confidence in interviews!
💬 Have a question? Drop it in the comments!

#SQLQueries #DataScience #SQLShortcuts #TechInterview #CareerGrowth

コメント