TGViewer
Data Analytics Data Analytics @sqlspecialist · 111K subscribers
Post #2223 4.91K
SQL Interview Questions with Answers Part-2: ☑️

11. What is a subquery? Give an example. 
    A subquery is a query nested inside another query (SELECT, INSERT, UPDATE, DELETE). It helps filter or calculate values dynamically. 
    Example:
SELECT name FROM employees  
WHERE department_id = (SELECT id FROM departments WHERE name = 'Sales');


12. Explain the concept of normalization. 
    Normalization is organizing data to minimize redundancy by dividing tables and defining relationships using keys. It improves data integrity and reduces update anomalies. Common normal forms: 1NF, 2NF, 3NF.

13. What is denormalization? When is it used? 
    Denormalization is combining tables to reduce joins, improving read performance at the cost of redundancy. Used in data warehousing or OLAP scenarios requiring fast query responses.

14. Describe transactions and their properties (ACID). 
    A transaction is a set of SQL operations treated as a single unit. ACID properties:
⦁ Atomicity: all or nothing execution
⦁ Consistency: database moves from one valid state to another
⦁ Isolation: concurrent transactions don’t interfere
⦁ Durability: changes persist after commit

15. What is a stored procedure? 
    A stored procedure is a precompiled SQL program stored in the database, which can accept parameters and perform complex operations efficiently, improving performance and reusability.

16. How do you handle NULL values in SQL? 
    Use IS NULL or IS NOT NULL to check NULLs. Functions like COALESCE() or IFNULL() replace NULLs with specified values in queries.

17. Explain the difference between UNION and UNION ALL.
⦁ UNION combines results of two queries and removes duplicates.
⦁ UNION ALL combines results including duplicates, faster than UNION.

18. What are views? How are they useful? 
    A view is a virtual table based on a SELECT query. It simplifies complex queries, provides security by restricting access, and allows data abstraction.

19. What is a trigger? Give use cases. 
    Triggers are special procedures that automatically execute in response to certain events on a table (e.g., INSERT, UPDATE). Use cases: auditing changes, enforcing business rules, cascading changes.

20. How do you perform aggregate functions in SQL? 
    Aggregate functions process multiple rows to return a single value, e.g., COUNT(), SUM(), AVG(), MIN(), and MAX(). Often used with GROUP BY to group results.

React ♥️ for Part 3
  • ❤ 18
More from @sqlspecialist
  1. Oct 17, 2026𝗜𝗕𝗠 𝗙𝗥𝗘𝗘 𝗧𝗘𝗖𝗛 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝟮𝟬𝟮𝟲! 🎓 Explore IBM Cognitive Class and build…
  2. Oct 16, 2026𝗗𝗮𝘁𝗮 𝘀𝗰𝗶𝗲𝗻𝗰𝗲 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗪𝗶𝘁𝗵 𝗔𝗜😍 Future Ready Data Scien…
  3. Oct 14, 2026I could then categorize customers into groups such as Active, At Risk, and Inactive and su…
  4. Oct 14, 2026📊 Data Analyst Interview Series — Part 10 Guys, let's continue our Data Analyst Interview…
  5. Oct 13, 2026📊 Data Analyst Interview Series — Part 9 Guys, let's continue our Data Analyst Interview…
  6. Oct 13, 2026𝗧𝗢𝗣 𝗙𝗥𝗘𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝗧𝗢 𝗕𝗢𝗢𝗦𝗧 𝗬𝗢𝗨𝗥 𝗦𝗞𝗜𝗟𝗟𝗦 𝗜𝗡 𝟮𝟬𝟮𝟲! Explor…
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 →