TGViewer
Data Analytics Data Analytics @sqlspecialist · 111K subscribers
Post #2224 5.07K
SQL interview questions Part-3 ✅

21. What is data partitioning? 
    Splitting large tables into smaller, manageable pieces (partitions) based on a key like date or region, improving query performance and maintenance.

22. How do you find duplicates in a table? 
    Use GROUP BY with HAVING:
SELECT column, COUNT(*)  
FROM table_name 
GROUP BY column 
HAVING COUNT(*) > 1; 


23. What is the difference between DELETE and TRUNCATE?
⦁ DELETE removes rows one by one, can have WHERE clause, logs each row, slower.
⦁ TRUNCATE removes all rows instantly, no WHERE, resets identity, faster but less flexible.

24. Explain window functions with examples. 
    Window functions perform calculations across sets of rows related to the current row without collapsing results. Example:
SELECT name, salary, RANK() OVER (ORDER BY salary DESC) AS salary_rank  
FROM employees; 


25. What is the difference between correlated and non-correlated subqueries?
⦁ Correlated subqueries depend on the outer query and execute for each row.
⦁ Non-correlated subqueries run independently once.

26. How do you enforce data integrity? 
    Using constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL), triggers, and transactions.

27. What are CTEs (Common Table Expressions)? 
    Temporary named result sets within SQL statements to improve query readability and recursion:
WITH cte AS (SELECT * FROM employees WHERE salary > 5000)  
SELECT * FROM cte; 


28. Explain EXISTS and NOT EXISTS operators.
⦁ EXISTS returns TRUE if a subquery returns any rows.
⦁ NOT EXISTS returns TRUE if subquery returns no rows.

29. How do SQL constraints work? 
    Constraints enforce rules at the database level to ensure data validity and integrity during insert/update/delete operations.

30. What is an execution plan? How do you use it? 
    A detailed roadmap of how SQL Server executes a query. Used to analyze and optimize query performance by revealing bottlenecks.

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