SQL Interview Questions
Kanalga Telegram’da o‘tish
Channel for SQL learning: @sql_res Chennal for SQL syntax: @sql_syntax Chennal for SQL interview questions: @etl_sql_interview
Ko'proq ko'rsatishMamlakat belgilanmaganToif belgilanmagan
2 405
Obunachilar
Ma'lumot yo'q24 soatlar
-27 kun
-1730 kun
Postlar arxiv
1. Answer : A. It transforms the
stored column values for every row before comparing them, preventing the query engine from navigating the pre-sorted B-Tree index structure using an index seek.
Reason: A condition is SARGable (Search Argument Able) only when the database engine can utilize an index seek directly on the raw column values stored in the B-Tree. Wrapping the column in a function alters its representation dynamically per row, necessitating a full index or table scan to compute the function value for each entry.
Sql Interview question:
1.
Why does applying a function like YEAR(order_date) on an indexed column inside a WHERE clause typically lead to a non-SARGable condition and a full table scan?
A. It transforms the stored column values for every row before comparing them, preventing the query engine from navigating the pre-sorted B-Tree index structure using an index seek.
B. It violates strict ACID normalization rules, causing the transaction log to lock the entire table instead of row-level locking.
C. It converts the data type from integer to varchar, triggering a catastrophic implicit conversion error that halts query execution.
D. It disables multi-threading capabilities, forcing the query optimizer to process records on a single CPU core sequentially.
https://t.me/AI_Agents_RAG_Learn/28
9 wonderful lectures for learning from Transformers to Agentic systems.
7th Lecture: Agentic LLMs
8th Lecture: LLM Evaluation, where most production teams need deep understanding.
Let's learn how to build Production graded Agentic AI in most effective way, roadmap, courses, links
https://t.me/AI_Agents_RAG_Learn
Leetcode SQL
Bit faster explanation
https://youtube.com/playlist?list=PLdrw9_aIADIPAMJW8I_S-S747oyiRtzpS
Detailed Explanation
https://youtube.com/playlist?list=PLtfxzVLWb-B-O3VAjxsoZYgG6d8WMnPjG
Commonly asked questions - Difference between concepts which looks similar but they aren't ( eg: where vs having, Exists vs In.. etc )
Part 1 :
https://youtu.be/RZc4QSRRk98
Part 2 :
https://youtu.be/s1QkS4PfiFg
Top 10 SQL interview queries for experienced
https://youtu.be/zvuWEysWoLE
SQL Interview Questions
Basic Level : https://intellipaat.com/blog/interview-question/sql-interview-questions/#11
Intermediate Level :
https://intellipaat.com/blog/interview-question/sql-interview-questions/#12
Advance Level :
https://intellipaat.com/blog/interview-question/sql-interview-questions/#13
MySQL Commands: Full List With Examples
https://www.interviewbit.com/blog/mysql-commands/?amp=1
To Refer three tables for writing queries👇
https://t.me/etl_sql_interview/8
To Refer questions for writing queries👇
https://t.me/etl_sql_interview/43
Answers :
41. SELECT DEPARTMENT, COUNT(DEPARTMENT) as 'Number of Workers' FROM Worker GROUP BY DEPARTMENT;
42. Select * from Worker where WORKER_ID = (SELECT max(WORKER_ID) from Worker);
43. Select * from Worker where WORKER_ID = (SELECT min(WORKER_ID) from Worker);
44. SELECT * FROM Worker WHERE WORKER_ID <=5
UNION
SELECT * FROM (SELECT * FROM Worker W order by W.WORKER_ID DESC) AS W1 WHERE W1.WORKER_ID <=5;
45. SELECT t.DEPARTMENT,t.FIRST_NAME,t.Salary from(SELECT max(Salary) as TotalSalary,DEPARTMENT from Worker group by DEPARTMENT) as TempNew
Inner Join Worker t on TempNew.DEPARTMENT=t.DEPARTMENT
and TempNew.TotalSalary=t.Salary;Click below link to Refer three tables here for writing queries 👇
https://t.me/etl_sql_interview/8
Q-41. Write an SQL query to show all departments along with the number of people in there.
Q-42. Write an SQL query to show the last record from a table.
Q-43. Write an SQL query to fetch the first row of a table.
Q-44. Write an SQL query to fetch the last five records from a table.
Q-45. Write an SQL query to print the name of employees having the highest salary in each department.
To Refer three tables for writing queries👇
https://t.me/etl_sql_interview/8
To Refer questions for writing queries👇
https://t.me/etl_sql_interview/41
Answers :
36. Select max(Salary) from Worker
where Salary not in (Select max(Salary) from Worker);
37. select FIRST_NAME, DEPARTMENT from worker W where W.DEPARTMENT='HR'
union all
select FIRST_NAME, DEPARTMENT from Worker W1 where W1.DEPARTMENT='HR';
38. (SELECT * FROM Worker)
INTERSECT
(SELECT * FROM WorkerClone);
39.SELECT *
FROM WORKER
WHERE WORKER_ID <= (SELECT count(WORKER_ID)/2 from Worker);
40. SELECT DEPARTMENT, COUNT(WORKER_ID) as 'Number of Workers' FROM Worker GROUP BY DEPARTMENT HAVING COUNT(WORKER_ID) < 5;Click below link to Refer three tables here for writing queries 👇
https://t.me/etl_sql_interview/8
Q-36. Write an SQL query to show the second highest salary from a table.
Q-37. Write an SQL query to show one row twice in results from a table.
Q-38. Write an SQL query to fetch intersecting records of two tables.
Q-39. Write an SQL query to fetch the first 50% records from a table.
Q-40. Write an SQL query to fetch the departments that have less than five people in it.
Most commonly asked SQL interview questions
https://youtu.be/L-URbfgxBMQ
