Top 10 Advanced SQL Interview Questions and Answers
1. What is a Common Table Expression (CTE), and when would you use it?
A Common Table Expression (CTE) is a temporary result set that can be referred to within a SELECT, INSERT, UPDATE, or DELETE statement.
Example:
2. How do you optimize a query with a large dataset?
- Use proper indexes.
- Avoid SELECT *; only retrieve required columns.
- Break down complex queries using temporary tables or CTEs.
- Analyze query execution plans.
3. What is the difference between RANK(), DENSE_RANK(), and ROW_NUMBER()?
- RANK(): Skips ranking if thereโs a tie (e.g., 1, 2, 2, 4).
- DENSE_RANK(): Does not skip ranks after a tie (e.g., 1, 2, 2, 3).
- ROW_NUMBER(): Assigns unique numbers sequentially, regardless of ties.
4. How do you find duplicate records in a table?
5. What is the difference between INNER JOIN and LEFT JOIN?
- INNER JOIN: Returns records that match in both tables.
- LEFT JOIN: Returns all records from the left table, and matching records from the right table (NULL if no match).
6. Explain window functions and provide an example.
Window functions operate on a set of rows related to the current row, without collapsing them into a single output.
Example:
7. What are the different types of indexes in SQL?
- Clustered Index: Reorders the data physically in the table.
- Non-Clustered Index: Creates a separate structure for data retrieval.
- Unique Index: Ensures no duplicate values in the column.
8. How do you handle NULL values in SQL?
- Use COALESCE() or ISNULL() to replace NULL values.
- Filter with IS NULL or IS NOT NULL in WHERE clauses.
Example:
9. What is the difference between DELETE and TRUNCATE?
- DELETE: Removes specific rows, can use WHERE clause, and logs individual row deletions.
- TRUNCATE: Removes all rows, faster, and resets table identity.
10. How do you use a CASE statement in SQL?
1. What is a Common Table Expression (CTE), and when would you use it?
A Common Table Expression (CTE) is a temporary result set that can be referred to within a SELECT, INSERT, UPDATE, or DELETE statement.
Example:
WITH SalesCTE AS (
SELECT SalespersonID, SUM(SalesAmount) AS TotalSales
FROM Sales
GROUP BY SalespersonID
)
SELECT * FROM SalesCTE WHERE TotalSales > 5000;
2. How do you optimize a query with a large dataset?
- Use proper indexes.
- Avoid SELECT *; only retrieve required columns.
- Break down complex queries using temporary tables or CTEs.
- Analyze query execution plans.
3. What is the difference between RANK(), DENSE_RANK(), and ROW_NUMBER()?
- RANK(): Skips ranking if thereโs a tie (e.g., 1, 2, 2, 4).
- DENSE_RANK(): Does not skip ranks after a tie (e.g., 1, 2, 2, 3).
- ROW_NUMBER(): Assigns unique numbers sequentially, regardless of ties.
4. How do you find duplicate records in a table?
SELECT ColumnName, COUNT(*)
FROM TableName
GROUP BY ColumnName
HAVING COUNT(*) > 1;
5. What is the difference between INNER JOIN and LEFT JOIN?
- INNER JOIN: Returns records that match in both tables.
- LEFT JOIN: Returns all records from the left table, and matching records from the right table (NULL if no match).
6. Explain window functions and provide an example.
Window functions operate on a set of rows related to the current row, without collapsing them into a single output.
Example:
SELECT EmployeeID, Salary,
RANK() OVER (PARTITION BY DepartmentID ORDER BY Salary DESC) AS Rank
FROM Employees;
7. What are the different types of indexes in SQL?
- Clustered Index: Reorders the data physically in the table.
- Non-Clustered Index: Creates a separate structure for data retrieval.
- Unique Index: Ensures no duplicate values in the column.
8. How do you handle NULL values in SQL?
- Use COALESCE() or ISNULL() to replace NULL values.
- Filter with IS NULL or IS NOT NULL in WHERE clauses.
Example:
SELECT COALESCE(PhoneNumber, 'N/A') AS ContactNumber FROM Customers;
9. What is the difference between DELETE and TRUNCATE?
- DELETE: Removes specific rows, can use WHERE clause, and logs individual row deletions.
- TRUNCATE: Removes all rows, faster, and resets table identity.
10. How do you use a CASE statement in SQL?
SELECT ProductName,
CASE
WHEN Quantity > 100 THEN 'High Stock'
WHEN Quantity BETWEEN 50 AND 100 THEN 'Medium Stock'
ELSE 'Low Stock'
END AS StockStatus
FROM Products;
๐5๐2
๐ฏ Top 20 SQL Interview Questions You Must Know
SQL is one of the most in-demand skills for Data Analysts.
Here are 20 SQL interview questions that frequently appear in job interviews.
๐ Basic SQL Questions
1๏ธโฃ What is the difference between INNER JOIN and LEFT JOIN?
2๏ธโฃ How does GROUP BY work, and why do we use it?
3๏ธโฃ What is the difference between HAVING and WHERE?
4๏ธโฃ How do you remove duplicate rows from a table?
5๏ธโฃ What is the difference between RANK(), DENSE_RANK(), and ROW_NUMBER()?
๐ Intermediate SQL Questions
6๏ธโฃ How do you find the second highest salary from an Employee table?
7๏ธโฃ What is a Common Table Expression (CTE), and when should you use it?
8๏ธโฃ How do you identify missing values in a dataset using SQL?
9๏ธโฃ What is the difference between UNION and UNION ALL?
๐ How do you calculate a running total in SQL?
๐ Advanced SQL Questions
1๏ธโฃ1๏ธโฃ How does a self-join work? Give an example.
1๏ธโฃ2๏ธโฃ What is a window function, and how is it different from GROUP BY?
1๏ธโฃ3๏ธโฃ How do you detect and remove duplicate records in SQL?
1๏ธโฃ4๏ธโฃ Explain the difference between EXISTS and IN.
1๏ธโฃ5๏ธโฃ What is the purpose of COALESCE()?
๐ Real-World SQL Scenarios
1๏ธโฃ6๏ธโฃ How do you optimize a slow SQL query?
1๏ธโฃ7๏ธโฃ What is indexing in SQL, and how does it improve performance?
1๏ธโฃ8๏ธโฃ Write an SQL query to find customers who have placed more than 3 orders.
1๏ธโฃ9๏ธโฃ How do you calculate the percentage of total sales for each category?
2๏ธโฃ0๏ธโฃ What is the use of CASE statements in SQL?
React โฅ๏ธ for more
SQL is one of the most in-demand skills for Data Analysts.
Here are 20 SQL interview questions that frequently appear in job interviews.
๐ Basic SQL Questions
1๏ธโฃ What is the difference between INNER JOIN and LEFT JOIN?
2๏ธโฃ How does GROUP BY work, and why do we use it?
3๏ธโฃ What is the difference between HAVING and WHERE?
4๏ธโฃ How do you remove duplicate rows from a table?
5๏ธโฃ What is the difference between RANK(), DENSE_RANK(), and ROW_NUMBER()?
๐ Intermediate SQL Questions
6๏ธโฃ How do you find the second highest salary from an Employee table?
7๏ธโฃ What is a Common Table Expression (CTE), and when should you use it?
8๏ธโฃ How do you identify missing values in a dataset using SQL?
9๏ธโฃ What is the difference between UNION and UNION ALL?
๐ How do you calculate a running total in SQL?
๐ Advanced SQL Questions
1๏ธโฃ1๏ธโฃ How does a self-join work? Give an example.
1๏ธโฃ2๏ธโฃ What is a window function, and how is it different from GROUP BY?
1๏ธโฃ3๏ธโฃ How do you detect and remove duplicate records in SQL?
1๏ธโฃ4๏ธโฃ Explain the difference between EXISTS and IN.
1๏ธโฃ5๏ธโฃ What is the purpose of COALESCE()?
๐ Real-World SQL Scenarios
1๏ธโฃ6๏ธโฃ How do you optimize a slow SQL query?
1๏ธโฃ7๏ธโฃ What is indexing in SQL, and how does it improve performance?
1๏ธโฃ8๏ธโฃ Write an SQL query to find customers who have placed more than 3 orders.
1๏ธโฃ9๏ธโฃ How do you calculate the percentage of total sales for each category?
2๏ธโฃ0๏ธโฃ What is the use of CASE statements in SQL?
React โฅ๏ธ for more
โค5๐2
Here are some commonly asked SQL interview questions along with brief answers:
1. What is SQL?
- SQL stands for Structured Query Language, used for managing and manipulating relational databases.
2. What are the types of SQL commands?
- SQL commands can be broadly categorized into four types: Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL).
3. What is the difference between CHAR and VARCHAR data types?
- CHAR is a fixed-length character data type, while VARCHAR is a variable-length character data type. CHAR will always occupy the same amount of storage space, while VARCHAR will only use the necessary space to store the actual data.
4. What is a primary key?
- A primary key is a column or a set of columns that uniquely identifies each row in a table. It ensures data integrity by enforcing uniqueness and can be used to establish relationships between tables.
5. What is a foreign key?
- A foreign key is a column or a set of columns in one table that refers to the primary key in another table. It establishes a relationship between two tables and ensures referential integrity.
6. What is a JOIN in SQL?
- JOIN is used to combine rows from two or more tables based on a related column between them. There are different types of JOINs, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
7. What is the difference between INNER JOIN and OUTER JOIN?
- INNER JOIN returns only the rows that have matching values in both tables, while OUTER JOIN (LEFT, RIGHT, FULL) returns all rows from one or both tables, with NULL values in columns where there is no match.
8. What is the difference between GROUP BY and ORDER BY?
- GROUP BY is used to group rows that have the same values into summary rows, typically used with aggregate functions like SUM, COUNT, AVG, etc., while ORDER BY is used to sort the result set based on one or more columns.
9. What is a subquery?
- A subquery is a query nested within another query, used to return data that will be used in the main query. Subqueries can be used in SELECT, INSERT, UPDATE, and DELETE statements.
10. What is normalization in SQL?
- Normalization is the process of organizing data in a database to reduce redundancy and dependency. It involves dividing large tables into smaller tables and defining relationships between them to improve data integrity and efficiency.
Around 90% questions will be asked from sql in data analytics interview, so please make sure to practice SQL skills using websites like stratascratch. โบ๏ธ๐ช
1. What is SQL?
- SQL stands for Structured Query Language, used for managing and manipulating relational databases.
2. What are the types of SQL commands?
- SQL commands can be broadly categorized into four types: Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL).
3. What is the difference between CHAR and VARCHAR data types?
- CHAR is a fixed-length character data type, while VARCHAR is a variable-length character data type. CHAR will always occupy the same amount of storage space, while VARCHAR will only use the necessary space to store the actual data.
4. What is a primary key?
- A primary key is a column or a set of columns that uniquely identifies each row in a table. It ensures data integrity by enforcing uniqueness and can be used to establish relationships between tables.
5. What is a foreign key?
- A foreign key is a column or a set of columns in one table that refers to the primary key in another table. It establishes a relationship between two tables and ensures referential integrity.
6. What is a JOIN in SQL?
- JOIN is used to combine rows from two or more tables based on a related column between them. There are different types of JOINs, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
7. What is the difference between INNER JOIN and OUTER JOIN?
- INNER JOIN returns only the rows that have matching values in both tables, while OUTER JOIN (LEFT, RIGHT, FULL) returns all rows from one or both tables, with NULL values in columns where there is no match.
8. What is the difference between GROUP BY and ORDER BY?
- GROUP BY is used to group rows that have the same values into summary rows, typically used with aggregate functions like SUM, COUNT, AVG, etc., while ORDER BY is used to sort the result set based on one or more columns.
9. What is a subquery?
- A subquery is a query nested within another query, used to return data that will be used in the main query. Subqueries can be used in SELECT, INSERT, UPDATE, and DELETE statements.
10. What is normalization in SQL?
- Normalization is the process of organizing data in a database to reduce redundancy and dependency. It involves dividing large tables into smaller tables and defining relationships between them to improve data integrity and efficiency.
Around 90% questions will be asked from sql in data analytics interview, so please make sure to practice SQL skills using websites like stratascratch. โบ๏ธ๐ช
๐6
Scenario based Interview Questions & Answers for Data Analyst
1. Scenario: You are working on a SQL database that stores customer information. The database has a table called "Orders" that contains order details. Your task is to write a SQL query to retrieve the total number of orders placed by each customer.
Question:
- Write a SQL query to find the total number of orders placed by each customer.
Expected Answer:
SELECT CustomerID, COUNT(*) AS TotalOrders
FROM Orders
GROUP BY CustomerID;
2. Scenario: You are working on a SQL database that stores employee information. The database has a table called "Employees" that contains employee details. Your task is to write a SQL query to retrieve the names of all employees who have been with the company for more than 5 years.
Question:
- Write a SQL query to find the names of employees who have been with the company for more than 5 years.
Expected Answer:
SELECT Name
FROM Employees
WHERE DATEDIFF(year, HireDate, GETDATE()) > 5;
Power BI Scenario-Based Questions
1. Scenario: You have been given a dataset in Power BI that contains sales data for a company. Your task is to create a report that shows the total sales by product category and region.
Expected Answer:
- Load the dataset into Power BI.
- Create relationships if necessary.
- Use the "Fields" pane to select the necessary fields (Product Category, Region, Sales).
- Drag these fields into the "Values" area of a new visualization (e.g., a table or bar chart).
- Use the "Filters" pane to filter data as needed.
- Format the visualization to enhance clarity and readability.
2. Scenario: You have been asked to create a Power BI dashboard that displays real-time stock prices for a set of companies. The stock prices are available through an API.
Expected Answer:
- Use Power BI Desktop to connect to the API.
- Go to "Get Data" > "Web" and enter the API URL.
- Configure the data refresh settings to ensure real-time updates (e.g., setting up a scheduled refresh or using DirectQuery if supported).
- Create visualizations using the imported data.
- Publish the report to the Power BI service and set up a data gateway if needed for continuous refresh.
3. Scenario: You have been given a Power BI report that contains multiple visualizations. The report is taking a long time to load and is impacting the performance of the application.
Expected Answer:
- Analyze the current performance using Performance Analyzer.
- Optimize data model by reducing the number of columns and rows, and removing unnecessary calculations.
- Use aggregated tables to pre-compute results.
- Simplify DAX calculations.
- Optimize visualizations by reducing the number of visuals per page and avoiding complex custom visuals.
- Ensure proper indexing on the data source.
Free SQL Resources: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like if you need more similar content
Hope it helps :)
1. Scenario: You are working on a SQL database that stores customer information. The database has a table called "Orders" that contains order details. Your task is to write a SQL query to retrieve the total number of orders placed by each customer.
Question:
- Write a SQL query to find the total number of orders placed by each customer.
Expected Answer:
SELECT CustomerID, COUNT(*) AS TotalOrders
FROM Orders
GROUP BY CustomerID;
2. Scenario: You are working on a SQL database that stores employee information. The database has a table called "Employees" that contains employee details. Your task is to write a SQL query to retrieve the names of all employees who have been with the company for more than 5 years.
Question:
- Write a SQL query to find the names of employees who have been with the company for more than 5 years.
Expected Answer:
SELECT Name
FROM Employees
WHERE DATEDIFF(year, HireDate, GETDATE()) > 5;
Power BI Scenario-Based Questions
1. Scenario: You have been given a dataset in Power BI that contains sales data for a company. Your task is to create a report that shows the total sales by product category and region.
Expected Answer:
- Load the dataset into Power BI.
- Create relationships if necessary.
- Use the "Fields" pane to select the necessary fields (Product Category, Region, Sales).
- Drag these fields into the "Values" area of a new visualization (e.g., a table or bar chart).
- Use the "Filters" pane to filter data as needed.
- Format the visualization to enhance clarity and readability.
2. Scenario: You have been asked to create a Power BI dashboard that displays real-time stock prices for a set of companies. The stock prices are available through an API.
Expected Answer:
- Use Power BI Desktop to connect to the API.
- Go to "Get Data" > "Web" and enter the API URL.
- Configure the data refresh settings to ensure real-time updates (e.g., setting up a scheduled refresh or using DirectQuery if supported).
- Create visualizations using the imported data.
- Publish the report to the Power BI service and set up a data gateway if needed for continuous refresh.
3. Scenario: You have been given a Power BI report that contains multiple visualizations. The report is taking a long time to load and is impacting the performance of the application.
Expected Answer:
- Analyze the current performance using Performance Analyzer.
- Optimize data model by reducing the number of columns and rows, and removing unnecessary calculations.
- Use aggregated tables to pre-compute results.
- Simplify DAX calculations.
- Optimize visualizations by reducing the number of visuals per page and avoiding complex custom visuals.
- Ensure proper indexing on the data source.
Free SQL Resources: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like if you need more similar content
Hope it helps :)
โค2๐2๐1
Database keys
Database keys are essential for organizing and managing data effectively. In this post, we'll explore ten key concepts that every IT professional should know.
1. ๐ ๐ฃ๐ฟ๐ถ๐บ๐ฎ๐ฟ๐ ๐๐ฒ๐
- A unique identifier for each record in a table.
- Cannot be null.
- Ensures that each row is unique.
2. ๐ ๐๐ผ๐ฟ๐ฒ๐ถ๐ด๐ป ๐๐ฒ๐
- A field in one table that refers to the Primary Key of another table.
- Establishes relationships between tables.
3. ๐งฉ ๐๐ผ๐บ๐ฝ๐ผ๐๐ถ๐๐ฒ ๐๐ฒ๐
- A combination of two or more columns that uniquely identifies each record.
- Useful when a single column can't uniquely identify a record.
4. ๐ช ๐ฆ๐๐ฝ๐ฒ๐ฟ ๐๐ฒ๐
- One or more columns that can uniquely identify a record.
- A Primary Key is a type of Super Key.
5. ๐ ๐๐ฎ๐ป๐ฑ๐ถ๐ฑ๐ฎ๐๐ฒ ๐๐ฒ๐
- A column or set of columns that could be the Primary Key.
- Must be unique.
6. ๐ ๐จ๐ป๐ถ๐พ๐๐ฒ ๐๐ฒ๐
- Ensures uniqueness for a column or column combination.
- Similar to Primary Key but allows one null value.
7. ๐ค ๐๐น๐๐ฒ๐ฟ๐ป๐ฎ๐๐ฒ ๐๐ฒ๐
- A Candidate Key that isn't the Primary Key.
- Another option for a unique identifier.
8. ๐ ๐ก๐ฎ๐๐๐ฟ๐ฎ๐น ๐๐ฒ๐
- A key that's a natural part of the data, like an email address.
9. ๐ญ ๐ฆ๐๐ฟ๐ฟ๐ผ๐ด๐ฎ๐๐ฒ ๐๐ฒ๐
- An artificial key created when no natural unique identifier exists.
10. ๐ ๐ฆ๐ฒ๐ฐ๐ผ๐ป๐ฑ๐ฎ๐ฟ๐ ๐๐ฒ๐
- Used for data retrieval, not identification.
- Helps create non-clustered indexes.
Database keys are essential for organizing and managing data effectively. In this post, we'll explore ten key concepts that every IT professional should know.
1. ๐ ๐ฃ๐ฟ๐ถ๐บ๐ฎ๐ฟ๐ ๐๐ฒ๐
- A unique identifier for each record in a table.
- Cannot be null.
- Ensures that each row is unique.
2. ๐ ๐๐ผ๐ฟ๐ฒ๐ถ๐ด๐ป ๐๐ฒ๐
- A field in one table that refers to the Primary Key of another table.
- Establishes relationships between tables.
3. ๐งฉ ๐๐ผ๐บ๐ฝ๐ผ๐๐ถ๐๐ฒ ๐๐ฒ๐
- A combination of two or more columns that uniquely identifies each record.
- Useful when a single column can't uniquely identify a record.
4. ๐ช ๐ฆ๐๐ฝ๐ฒ๐ฟ ๐๐ฒ๐
- One or more columns that can uniquely identify a record.
- A Primary Key is a type of Super Key.
5. ๐ ๐๐ฎ๐ป๐ฑ๐ถ๐ฑ๐ฎ๐๐ฒ ๐๐ฒ๐
- A column or set of columns that could be the Primary Key.
- Must be unique.
6. ๐ ๐จ๐ป๐ถ๐พ๐๐ฒ ๐๐ฒ๐
- Ensures uniqueness for a column or column combination.
- Similar to Primary Key but allows one null value.
7. ๐ค ๐๐น๐๐ฒ๐ฟ๐ป๐ฎ๐๐ฒ ๐๐ฒ๐
- A Candidate Key that isn't the Primary Key.
- Another option for a unique identifier.
8. ๐ ๐ก๐ฎ๐๐๐ฟ๐ฎ๐น ๐๐ฒ๐
- A key that's a natural part of the data, like an email address.
9. ๐ญ ๐ฆ๐๐ฟ๐ฟ๐ผ๐ด๐ฎ๐๐ฒ ๐๐ฒ๐
- An artificial key created when no natural unique identifier exists.
10. ๐ ๐ฆ๐ฒ๐ฐ๐ผ๐ป๐ฑ๐ฎ๐ฟ๐ ๐๐ฒ๐
- Used for data retrieval, not identification.
- Helps create non-clustered indexes.
๐4๐1
1. What is a Self-Join?
A self-join is a type of join that can be used to connect two tables. As a result, it is a unary relationship. Each row of the table is attached to itself and all other rows of the same table in a self-join. As a result, a self-join is mostly used to combine and compare rows from the same database table.
2. What is OLTP?
OLTP, or online transactional processing, allows huge groups of people to execute massive amounts of database transactions in real time, usually via the internet. A database transaction occurs when data in a database is changed, inserted, deleted, or queried.
3. What is the difference between joining and blending in Tableau?
Joining term is used when you are combining data from the same source, for example, worksheet in an Excel file or tables in Oracle databaseWhile blending requires two completely defined data sources in your report.
4. How to prevent someone from copying the cell from your worksheet in excel?
If you want to protect your worksheet from being copied, go into Menu bar > Review > Protect sheet > Password.
By entering password you can prevent your worksheet from getting copied.
5. What are the different integrity rules present in the DBMS?
The different integrity rules present in DBMS are as follows:
Entity Integrity: This rule states that the value of the primary key can never be NULL. So, all the tuples in the column identified as the primary key should have a value.
Referential Integrity: This rule states that either the value of the foreign key is NULL or it should be the primary key of any other relation.
A self-join is a type of join that can be used to connect two tables. As a result, it is a unary relationship. Each row of the table is attached to itself and all other rows of the same table in a self-join. As a result, a self-join is mostly used to combine and compare rows from the same database table.
2. What is OLTP?
OLTP, or online transactional processing, allows huge groups of people to execute massive amounts of database transactions in real time, usually via the internet. A database transaction occurs when data in a database is changed, inserted, deleted, or queried.
3. What is the difference between joining and blending in Tableau?
Joining term is used when you are combining data from the same source, for example, worksheet in an Excel file or tables in Oracle databaseWhile blending requires two completely defined data sources in your report.
4. How to prevent someone from copying the cell from your worksheet in excel?
If you want to protect your worksheet from being copied, go into Menu bar > Review > Protect sheet > Password.
By entering password you can prevent your worksheet from getting copied.
5. What are the different integrity rules present in the DBMS?
The different integrity rules present in DBMS are as follows:
Entity Integrity: This rule states that the value of the primary key can never be NULL. So, all the tuples in the column identified as the primary key should have a value.
Referential Integrity: This rule states that either the value of the foreign key is NULL or it should be the primary key of any other relation.
๐1
SQL Interview Questions for 0-1 year of Experience (Asked in Top Product-Based Companies).
Sharpen your SQL skills with these real interview questions!
Q1. Customer Purchase Patterns -
You have two tables, Customers and Purchases: CREATE TABLE Customers ( customer_id INT PRIMARY KEY, customer_name VARCHAR(255) ); CREATE TABLE Purchases ( purchase_id INT PRIMARY KEY, customer_id INT, product_id INT, purchase_date DATE );
Assume necessary INSERT statements are already executed.
Write an SQL query to find the names of customers who have purchased more than 5 different products within the last month. Order the result by customer_name.
Q2. Call Log Analysis -
Suppose you have a CallLogs table: CREATE TABLE CallLogs ( log_id INT PRIMARY KEY, caller_id INT, receiver_id INT, call_start_time TIMESTAMP, call_end_time TIMESTAMP );
Assume necessary INSERT statements are already executed.
Write a query to find the average call duration per user. Include only users who have made more than 10 calls in total. Order the result by average duration descending.
Q3. Employee Project Allocation - Consider two tables, Employees and Projects:
CREATE TABLE Employees ( employee_id INT PRIMARY KEY, employee_name VARCHAR(255), department VARCHAR(255) ); CREATE TABLE Projects ( project_id INT PRIMARY KEY, lead_employee_id INT, project_name VARCHAR(255), start_date DATE, end_date DATE );
Assume necessary INSERT statements are already executed.
The goal is to write an SQL query to find the names of employees who have led more than 3 projects in the last year. The result should be ordered by the number of projects led.
Sharpen your SQL skills with these real interview questions!
Q1. Customer Purchase Patterns -
You have two tables, Customers and Purchases: CREATE TABLE Customers ( customer_id INT PRIMARY KEY, customer_name VARCHAR(255) ); CREATE TABLE Purchases ( purchase_id INT PRIMARY KEY, customer_id INT, product_id INT, purchase_date DATE );
Assume necessary INSERT statements are already executed.
Write an SQL query to find the names of customers who have purchased more than 5 different products within the last month. Order the result by customer_name.
Q2. Call Log Analysis -
Suppose you have a CallLogs table: CREATE TABLE CallLogs ( log_id INT PRIMARY KEY, caller_id INT, receiver_id INT, call_start_time TIMESTAMP, call_end_time TIMESTAMP );
Assume necessary INSERT statements are already executed.
Write a query to find the average call duration per user. Include only users who have made more than 10 calls in total. Order the result by average duration descending.
Q3. Employee Project Allocation - Consider two tables, Employees and Projects:
CREATE TABLE Employees ( employee_id INT PRIMARY KEY, employee_name VARCHAR(255), department VARCHAR(255) ); CREATE TABLE Projects ( project_id INT PRIMARY KEY, lead_employee_id INT, project_name VARCHAR(255), start_date DATE, end_date DATE );
Assume necessary INSERT statements are already executed.
The goal is to write an SQL query to find the names of employees who have led more than 3 projects in the last year. The result should be ordered by the number of projects led.
๐4
The Secret to learn SQL:
It's not about knowing everything
It's about doing simple things well
What You ACTUALLY Need:
1. SELECT Mastery
* SELECT * LIMIT 10
(yes, for exploration only!)
* COUNT, SUM, AVG
(used every single day)
* Basic DATE functions
(life-saving for reports)
* CASE WHEN
2. JOIN Logic
* LEFT JOIN
(your best friend)
* INNER JOIN
(your second best friend)
* That's it.
3. WHERE Magic
* Basic conditions
* AND, OR operators
* IN, NOT IN
* NULL handling
* LIKE for text search
4. GROUP BY Essentials
* Basic grouping
* HAVING clause
* Multiple columns
* Simple aggregations
Most common tasks:
* Pull monthly sales
* Count unique customers
* Calculate basic metrics
* Filter date ranges
* Join 2-3 tables
Focus on:
* Clean code
* Clear comments
* Consistent formatting
* Proper indentation
Here you can find essential SQL Interview Resources๐
https://t.iss.one/mysqldata
Like this post if you need more ๐โค๏ธ
Hope it helps :)
#sql
It's not about knowing everything
It's about doing simple things well
What You ACTUALLY Need:
1. SELECT Mastery
* SELECT * LIMIT 10
(yes, for exploration only!)
* COUNT, SUM, AVG
(used every single day)
* Basic DATE functions
(life-saving for reports)
* CASE WHEN
2. JOIN Logic
* LEFT JOIN
(your best friend)
* INNER JOIN
(your second best friend)
* That's it.
3. WHERE Magic
* Basic conditions
* AND, OR operators
* IN, NOT IN
* NULL handling
* LIKE for text search
4. GROUP BY Essentials
* Basic grouping
* HAVING clause
* Multiple columns
* Simple aggregations
Most common tasks:
* Pull monthly sales
* Count unique customers
* Calculate basic metrics
* Filter date ranges
* Join 2-3 tables
Focus on:
* Clean code
* Clear comments
* Consistent formatting
* Proper indentation
Here you can find essential SQL Interview Resources๐
https://t.iss.one/mysqldata
Like this post if you need more ๐โค๏ธ
Hope it helps :)
#sql
๐5
SQL Advanced Concepts for Data Analyst Interviews
1. Window Functions: Gain proficiency in window functions like
2. Common Table Expressions (CTEs): Understand how to use CTEs with the
3. Recursive CTEs: Learn how to use recursive CTEs to solve hierarchical or recursive data problems, such as navigating organizational charts or bill-of-materials structures.
4. Advanced Joins: Master complex join techniques, including self-joins (joining a table with itself), cross joins (Cartesian product), and using multiple joins in a single query.
5. Subqueries and Correlated Subqueries: Be adept at writing subqueries that return a single value or a set of values. Correlated subqueries, which reference columns from the outer query, are particularly powerful for row-by-row operations.
6. Indexing Strategies: Learn advanced indexing strategies, such as covering indexes, composite indexes, and partial indexes. Understand how to optimize query performance by designing the right indexes and when to use
7. Query Optimization and Execution Plans: Develop skills in reading and interpreting SQL execution plans to understand how queries are executed. Use tools like
8. Stored Procedures: Understand how to create and use stored procedures to encapsulate complex SQL logic into reusable, modular code. Learn how to pass parameters, handle errors, and return multiple result sets from a stored procedure.
9. Triggers: Learn how to create triggers to automatically execute a specified action in response to certain events on a table (e.g.,
10. Transactions and Isolation Levels: Master the use of transactions to ensure that a series of SQL operations are executed as a single unit of work. Understand different isolation levels (
11. PIVOT and UNPIVOT: Use the
12. Dynamic SQL: Learn how to write dynamic SQL queries that are constructed and executed at runtime. This is useful when the exact SQL query cannot be determined until runtime, such as in scenarios involving user-defined filters or conditional logic.
13. Data Partitioning: Understand how to implement data partitioning strategies, such as range partitioning or list partitioning, to manage large tables efficiently. Partitioning can significantly improve query performance and manageability.
14. Temporary Tables: Learn how to create and use temporary tables to store intermediate results within a session. Understand the differences between local and global temporary tables, and when to use them.
15. Materialized Views: Use materialized views to store the result of a query physically and update it periodically. This can drastically improve performance for complex queries that need to be executed frequently.
16. Handling Complex Data Types: Understand how to work with complex data types such as JSON, XML, and arrays. Learn how to store, query, and manipulate these types in SQL databases, including using functions like
Here you can find SQL Interview Resources๐
https://t.iss.one/DataSimplifier
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
1. Window Functions: Gain proficiency in window functions like
ROW_NUMBER(), RANK(), DENSE_RANK(), NTILE(), and LAG()/LEAD(). These functions allow you to perform calculations across a set of table rows related to the current row without collapsing the result set into a single output.2. Common Table Expressions (CTEs): Understand how to use CTEs with the
WITH clause to create temporary result sets that can be referenced within a SELECT, INSERT, UPDATE, or DELETE statement. CTEs improve the readability and maintainability of complex queries.3. Recursive CTEs: Learn how to use recursive CTEs to solve hierarchical or recursive data problems, such as navigating organizational charts or bill-of-materials structures.
4. Advanced Joins: Master complex join techniques, including self-joins (joining a table with itself), cross joins (Cartesian product), and using multiple joins in a single query.
5. Subqueries and Correlated Subqueries: Be adept at writing subqueries that return a single value or a set of values. Correlated subqueries, which reference columns from the outer query, are particularly powerful for row-by-row operations.
6. Indexing Strategies: Learn advanced indexing strategies, such as covering indexes, composite indexes, and partial indexes. Understand how to optimize query performance by designing the right indexes and when to use
CLUSTERED versus NON-CLUSTERED indexes.7. Query Optimization and Execution Plans: Develop skills in reading and interpreting SQL execution plans to understand how queries are executed. Use tools like
EXPLAIN or EXPLAIN ANALYZE to identify performance bottlenecks and optimize query performance.8. Stored Procedures: Understand how to create and use stored procedures to encapsulate complex SQL logic into reusable, modular code. Learn how to pass parameters, handle errors, and return multiple result sets from a stored procedure.
9. Triggers: Learn how to create triggers to automatically execute a specified action in response to certain events on a table (e.g.,
AFTER INSERT, BEFORE UPDATE). Triggers are useful for maintaining data integrity and automating workflows.10. Transactions and Isolation Levels: Master the use of transactions to ensure that a series of SQL operations are executed as a single unit of work. Understand different isolation levels (
READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE) and their impact on data consistency and concurrency.11. PIVOT and UNPIVOT: Use the
PIVOT operator to transform row data into columnar data and UNPIVOT to convert columns back into rows. These operations are crucial for reshaping data for reporting and analysis.12. Dynamic SQL: Learn how to write dynamic SQL queries that are constructed and executed at runtime. This is useful when the exact SQL query cannot be determined until runtime, such as in scenarios involving user-defined filters or conditional logic.
13. Data Partitioning: Understand how to implement data partitioning strategies, such as range partitioning or list partitioning, to manage large tables efficiently. Partitioning can significantly improve query performance and manageability.
14. Temporary Tables: Learn how to create and use temporary tables to store intermediate results within a session. Understand the differences between local and global temporary tables, and when to use them.
15. Materialized Views: Use materialized views to store the result of a query physically and update it periodically. This can drastically improve performance for complex queries that need to be executed frequently.
16. Handling Complex Data Types: Understand how to work with complex data types such as JSON, XML, and arrays. Learn how to store, query, and manipulate these types in SQL databases, including using functions like
JSON_EXTRACT(), XMLQUERY(), or array functions.Here you can find SQL Interview Resources๐
https://t.iss.one/DataSimplifier
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
๐3๐1
Starting the SQL Learning Series on WhatsApp Channel
๐๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v/1075
๐๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v/1075
๐2โค1
Quick Recap of SQL Concepts
1. What is SQL?
SQL (Structured Query Language) is a standard programming language used for managing and manipulating relational databases.
2. What are the different types of SQL commands?
- Data Definition Language (DDL): Used to define the structure of database objects (CREATE, ALTER, DROP).
- Data Manipulation Language (DML): Used to manipulate data in the database (SELECT, INSERT, UPDATE, DELETE).
- Data Control Language (DCL): Used to control access and permissions on database objects (GRANT, REVOKE).
3. What is a database schema?
A database schema is a logical structure that represents the layout of the database, including tables, columns, relationships, constraints, and indexes.
4. What is a primary key?
A primary key is a unique identifier for each record in a table. It ensures that each row in the table is uniquely identified and helps maintain data integrity.
5. What is a foreign key?
A foreign key is a column or set of columns in one table that references the primary key in another table. It establishes a relationship between the two tables.
6. What is normalization in SQL?
Normalization is the process of organizing data in a database to reduce redundancy and dependency by dividing large tables into smaller tables and defining relationships between them.
7. What is an index in SQL?
An index is a data structure that improves the speed of data retrieval operations on a database table. It allows for faster searching and sorting of data based on specific columns.
8. What is a JOIN in SQL?
A JOIN is used to combine rows from two or more tables based on a related column between them. Common types of JOINs include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
9. What is a subquery in SQL?
A subquery is a query nested within another query. It allows you to perform complex queries by using the result of one query as input for another query.
10. What is the difference between SQL and NoSQL databases?
- SQL databases are relational databases that store data in structured tables with predefined schemas, while NoSQL databases are non-relational databases that store data in flexible, schema-less formats.
- SQL databases use SQL for querying and manipulating data, while NoSQL databases use various query languages or APIs.
- SQL databases are suitable for complex queries and transactions, while NoSQL databases are better for handling large volumes of unstructured data and scaling horizontally.
Hope it helps :)
1. What is SQL?
SQL (Structured Query Language) is a standard programming language used for managing and manipulating relational databases.
2. What are the different types of SQL commands?
- Data Definition Language (DDL): Used to define the structure of database objects (CREATE, ALTER, DROP).
- Data Manipulation Language (DML): Used to manipulate data in the database (SELECT, INSERT, UPDATE, DELETE).
- Data Control Language (DCL): Used to control access and permissions on database objects (GRANT, REVOKE).
3. What is a database schema?
A database schema is a logical structure that represents the layout of the database, including tables, columns, relationships, constraints, and indexes.
4. What is a primary key?
A primary key is a unique identifier for each record in a table. It ensures that each row in the table is uniquely identified and helps maintain data integrity.
5. What is a foreign key?
A foreign key is a column or set of columns in one table that references the primary key in another table. It establishes a relationship between the two tables.
6. What is normalization in SQL?
Normalization is the process of organizing data in a database to reduce redundancy and dependency by dividing large tables into smaller tables and defining relationships between them.
7. What is an index in SQL?
An index is a data structure that improves the speed of data retrieval operations on a database table. It allows for faster searching and sorting of data based on specific columns.
8. What is a JOIN in SQL?
A JOIN is used to combine rows from two or more tables based on a related column between them. Common types of JOINs include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
9. What is a subquery in SQL?
A subquery is a query nested within another query. It allows you to perform complex queries by using the result of one query as input for another query.
10. What is the difference between SQL and NoSQL databases?
- SQL databases are relational databases that store data in structured tables with predefined schemas, while NoSQL databases are non-relational databases that store data in flexible, schema-less formats.
- SQL databases use SQL for querying and manipulating data, while NoSQL databases use various query languages or APIs.
- SQL databases are suitable for complex queries and transactions, while NoSQL databases are better for handling large volumes of unstructured data and scaling horizontally.
Hope it helps :)
๐9
Guys, Big Announcement!
Iโm launching a Complete SQL Learning Series โ designed for everyone โ whether you're a beginner, intermediate, or someone preparing for data interviews.
This is a complete step-by-step journey โ from scratch to advanced โ filled with practical examples, relatable scenarios, and short quizzes after each topic to solidify your learning.
Hereโs the 5-Week Plan:
Week 1: SQL Fundamentals (No Prior Knowledge Needed)
- What is SQL? Real-world Use Cases
- Databases vs Tables
- SELECT Queries โ The Heart of SQL
- Filtering Data with WHERE
- Sorting with ORDER BY
- Using DISTINCT and LIMIT
- Basic Arithmetic and Column Aliases
Week 2: Aggregations & Grouping
- COUNT, SUM, AVG, MIN, MAX โ When and How
- GROUP BY โ The Right Way
- HAVING vs WHERE
- Dealing with NULLs in Aggregations
- CASE Statements for Conditional Logic
*Week 3: Mastering JOINS & Relationships*
- Understanding Table Relationships (1-to-1, 1-to-Many)
- INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN
- Practical Examples with Two or More Tables
- SELF JOIN & CROSS JOIN โ What, When & Why
- Common Join Mistakes & Fixes
Week 4: Advanced SQL Concepts
- Subqueries: Writing Queries Inside Queries
- CTEs (WITH Clause): Cleaner & More Readable SQL
- Window Functions: RANK, DENSE_RANK, ROW_NUMBER
- Using PARTITION BY and ORDER BY
- EXISTS vs IN: Performance and Use Cases
Week 5: Real-World Scenarios & Interview-Ready SQL
- Using SQL to Solve Real Business Problems
- SQL for Sales, Marketing, HR & Product Analytics
- Writing Clean, Efficient & Complex Queries
- Most Common SQL Interview Questions like:
โFind the second highest salaryโ
โDetect duplicates in a tableโ
โCalculate running totalsโ
โIdentify top N products per categoryโ
- Practice Challenges Based on Real Interviews
React with โค๏ธ if you're ready for this series
Join our WhatsApp channel to access it: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v/1075
Iโm launching a Complete SQL Learning Series โ designed for everyone โ whether you're a beginner, intermediate, or someone preparing for data interviews.
This is a complete step-by-step journey โ from scratch to advanced โ filled with practical examples, relatable scenarios, and short quizzes after each topic to solidify your learning.
Hereโs the 5-Week Plan:
Week 1: SQL Fundamentals (No Prior Knowledge Needed)
- What is SQL? Real-world Use Cases
- Databases vs Tables
- SELECT Queries โ The Heart of SQL
- Filtering Data with WHERE
- Sorting with ORDER BY
- Using DISTINCT and LIMIT
- Basic Arithmetic and Column Aliases
Week 2: Aggregations & Grouping
- COUNT, SUM, AVG, MIN, MAX โ When and How
- GROUP BY โ The Right Way
- HAVING vs WHERE
- Dealing with NULLs in Aggregations
- CASE Statements for Conditional Logic
*Week 3: Mastering JOINS & Relationships*
- Understanding Table Relationships (1-to-1, 1-to-Many)
- INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN
- Practical Examples with Two or More Tables
- SELF JOIN & CROSS JOIN โ What, When & Why
- Common Join Mistakes & Fixes
Week 4: Advanced SQL Concepts
- Subqueries: Writing Queries Inside Queries
- CTEs (WITH Clause): Cleaner & More Readable SQL
- Window Functions: RANK, DENSE_RANK, ROW_NUMBER
- Using PARTITION BY and ORDER BY
- EXISTS vs IN: Performance and Use Cases
Week 5: Real-World Scenarios & Interview-Ready SQL
- Using SQL to Solve Real Business Problems
- SQL for Sales, Marketing, HR & Product Analytics
- Writing Clean, Efficient & Complex Queries
- Most Common SQL Interview Questions like:
โFind the second highest salaryโ
โDetect duplicates in a tableโ
โCalculate running totalsโ
โIdentify top N products per categoryโ
- Practice Challenges Based on Real Interviews
React with โค๏ธ if you're ready for this series
Join our WhatsApp channel to access it: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v/1075
โค17๐2๐1
Complete SQL road map
๐๐
1.Intro to SQL
โข Definition
โข Purpose
โข Relational DBs
โข DBMS
2.Basic SQL Syntax
โข SELECT
โข FROM
โข WHERE
โข ORDER BY
โข GROUP BY
3. Data Types
โข Integer
โข Floating-Point
โข Character
โข Date
โข VARCHAR
โข TEXT
โข BLOB
โข BOOLEAN
4.Sub languages
โข DML
โข DDL
โข DQL
โข DCL
โข TCL
5. Data Manipulation
โข INSERT
โข UPDATE
โข DELETE
6. Data Definition
โข CREATE
โข ALTER
โข DROP
โข Indexes
7.Query Filtering and Sorting
โข WHERE
โข AND
โข OR Conditions
โข Ascending
โข Descending
8. Data Aggregation
โข SUM
โข AVG
โข COUNT
โข MIN
โข MAX
9.Joins and Relationships
โข INNER JOIN
โข LEFT JOIN
โข RIGHT JOIN
โข Self-Joins
โข Cross Joins
โข FULL OUTER JOIN
10.Subqueries
โข Subqueries used in
โข Filtering data
โข Aggregating data
โข Joining tables
โข Correlated Subqueries
11.Views
โข Creating
โข Modifying
โข Dropping Views
12.Transactions
โข ACID Properties
โข COMMIT
โข ROLLBACK
โข SAVEPOINT
โข ROLLBACK TO SAVEPOINT
13.Stored Procedures
โข CREATE PROCEDURE
โข ALTER PROCEDURE
โข DROP PROCEDURE
โข EXECUTE PROCEDURE
โข User-Defined Functions (UDFs)
14.Triggers
โข Trigger Events
โข Trigger Execution and Syntax
15. Security and Permissions
โข CREATE USER
โข GRANT
โข REVOKE
โข ALTER USER
โข DROP USER
16.Optimizations
โข Indexing Strategies
โข Query Optimization
17.Normalization
โข 1NF(Normal Form)
โข 2NF
โข 3NF
โข BCNF
18.Backup and Recovery
โข Database Backups
โข Point-in-Time Recovery
19.NoSQL Databases
โข MongoDB
โข Cassandra etc...
โข Key differences
20. Data Integrity
โข Primary Key
โข Foreign Key
21.Advanced SQL Queries
โข Window Functions
โข Common Table Expressions (CTEs)
22.Full-Text Search
โข Full-Text Indexes
โข Search Optimization
23. Data Import and Export
โข Importing Data
โข Exporting Data (CSV, JSON)
โข Using SQL Dump Files
24.Database Design
โข Entity-Relationship Diagrams
โข Normalization Techniques
25.Advanced Indexing
โข Composite Indexes
โข Covering Indexes
26.Database Transactions
โข Savepoints
โข Nested Transactions
โข Two-Phase Commit Protocol
27.Performance Tuning
โข Query Profiling and Analysis
โข Query Cache Optimization
------------------ END -------------------
Some good resources to learn SQL
1.Tutorial & Courses
โข Learn SQL: https://bit.ly/3FxxKPz
โข Udacity: imp.i115008.net/AoAg7K
2. YouTube Channel's
โข FreeCodeCamp:rb.gy/pprz73
โข Programming with Mosh: rb.gy/g62hpe
3. Books
โข SQL in a Nutshell: https://t.iss.one/DataAnalystInterview/158
4. SQL Interview Questions
https://t.iss.one/sqlanalyst/72?single
Join @free4unow_backup for more free resourses
ENJOY LEARNING ๐๐
๐๐
1.Intro to SQL
โข Definition
โข Purpose
โข Relational DBs
โข DBMS
2.Basic SQL Syntax
โข SELECT
โข FROM
โข WHERE
โข ORDER BY
โข GROUP BY
3. Data Types
โข Integer
โข Floating-Point
โข Character
โข Date
โข VARCHAR
โข TEXT
โข BLOB
โข BOOLEAN
4.Sub languages
โข DML
โข DDL
โข DQL
โข DCL
โข TCL
5. Data Manipulation
โข INSERT
โข UPDATE
โข DELETE
6. Data Definition
โข CREATE
โข ALTER
โข DROP
โข Indexes
7.Query Filtering and Sorting
โข WHERE
โข AND
โข OR Conditions
โข Ascending
โข Descending
8. Data Aggregation
โข SUM
โข AVG
โข COUNT
โข MIN
โข MAX
9.Joins and Relationships
โข INNER JOIN
โข LEFT JOIN
โข RIGHT JOIN
โข Self-Joins
โข Cross Joins
โข FULL OUTER JOIN
10.Subqueries
โข Subqueries used in
โข Filtering data
โข Aggregating data
โข Joining tables
โข Correlated Subqueries
11.Views
โข Creating
โข Modifying
โข Dropping Views
12.Transactions
โข ACID Properties
โข COMMIT
โข ROLLBACK
โข SAVEPOINT
โข ROLLBACK TO SAVEPOINT
13.Stored Procedures
โข CREATE PROCEDURE
โข ALTER PROCEDURE
โข DROP PROCEDURE
โข EXECUTE PROCEDURE
โข User-Defined Functions (UDFs)
14.Triggers
โข Trigger Events
โข Trigger Execution and Syntax
15. Security and Permissions
โข CREATE USER
โข GRANT
โข REVOKE
โข ALTER USER
โข DROP USER
16.Optimizations
โข Indexing Strategies
โข Query Optimization
17.Normalization
โข 1NF(Normal Form)
โข 2NF
โข 3NF
โข BCNF
18.Backup and Recovery
โข Database Backups
โข Point-in-Time Recovery
19.NoSQL Databases
โข MongoDB
โข Cassandra etc...
โข Key differences
20. Data Integrity
โข Primary Key
โข Foreign Key
21.Advanced SQL Queries
โข Window Functions
โข Common Table Expressions (CTEs)
22.Full-Text Search
โข Full-Text Indexes
โข Search Optimization
23. Data Import and Export
โข Importing Data
โข Exporting Data (CSV, JSON)
โข Using SQL Dump Files
24.Database Design
โข Entity-Relationship Diagrams
โข Normalization Techniques
25.Advanced Indexing
โข Composite Indexes
โข Covering Indexes
26.Database Transactions
โข Savepoints
โข Nested Transactions
โข Two-Phase Commit Protocol
27.Performance Tuning
โข Query Profiling and Analysis
โข Query Cache Optimization
------------------ END -------------------
Some good resources to learn SQL
1.Tutorial & Courses
โข Learn SQL: https://bit.ly/3FxxKPz
โข Udacity: imp.i115008.net/AoAg7K
2. YouTube Channel's
โข FreeCodeCamp:rb.gy/pprz73
โข Programming with Mosh: rb.gy/g62hpe
3. Books
โข SQL in a Nutshell: https://t.iss.one/DataAnalystInterview/158
4. SQL Interview Questions
https://t.iss.one/sqlanalyst/72?single
Join @free4unow_backup for more free resourses
ENJOY LEARNING ๐๐
๐12โค1
๐๐๐ ๐๐๐ฌ๐ ๐๐ญ๐ฎ๐๐ข๐๐ฌ ๐๐จ๐ซ ๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ:
Join for more: https://t.iss.one/sqlanalyst
1. Dannyโs Diner:
Restaurant analytics to understand the customer orders pattern.
Link: https://8weeksqlchallenge.com/case-study-1/
2. Pizza Runner
Pizza shop analytics to optimize the efficiency of the operation
Link: https://8weeksqlchallenge.com/case-study-2/
3. Foodie Fie
Subscription-based food content platform
Link: https://lnkd.in/gzB39qAT
4. Data Bank: Thatโs money
Analytics based on customer activities with the digital bank
Link: https://lnkd.in/gH8pKPyv
5. Data Mart: Fresh is Best
Analytics on Online supermarket
Link: https://lnkd.in/gC5bkcDf
6. Clique Bait: Attention capturing
Analytics on the seafood industry
Link: https://lnkd.in/ggP4JiYG
7. Balanced Tree: Clothing Company
Analytics on the sales performance of clothing store
Link: https://8weeksqlchallenge.com/case-study-7
8. Fresh segments: Extract maximum value
Analytics on online advertising
Link: https://8weeksqlchallenge.com/case-study-8
Join for more: https://t.iss.one/sqlanalyst
1. Dannyโs Diner:
Restaurant analytics to understand the customer orders pattern.
Link: https://8weeksqlchallenge.com/case-study-1/
2. Pizza Runner
Pizza shop analytics to optimize the efficiency of the operation
Link: https://8weeksqlchallenge.com/case-study-2/
3. Foodie Fie
Subscription-based food content platform
Link: https://lnkd.in/gzB39qAT
4. Data Bank: Thatโs money
Analytics based on customer activities with the digital bank
Link: https://lnkd.in/gH8pKPyv
5. Data Mart: Fresh is Best
Analytics on Online supermarket
Link: https://lnkd.in/gC5bkcDf
6. Clique Bait: Attention capturing
Analytics on the seafood industry
Link: https://lnkd.in/ggP4JiYG
7. Balanced Tree: Clothing Company
Analytics on the sales performance of clothing store
Link: https://8weeksqlchallenge.com/case-study-7
8. Fresh segments: Extract maximum value
Analytics on online advertising
Link: https://8weeksqlchallenge.com/case-study-8
๐5
Advanced Questions Asked by Big 4
๐ Excel Questions
1. How do you use Excel to forecast future trends based on historical data? Describe a scenario where you built a forecasting model.
2. Can you explain how you would automate repetitive tasks in Excel using VBA (Visual Basic for Applications)? Provide an example of a complex macro you created.
3. Describe a time when you had to merge and analyze data from multiple Excel workbooks. How did you ensure data integrity and accuracy?
๐ SQL Questions
1. How would you design a database schema for a new e-commerce platform to efficiently handle large volumes of transactions and user data?
2. Describe a complex SQL query you wrote to solve a business problem. What was the problem, and how did your query help resolve it?
3. How do you ensure data integrity and consistency in a multi-user database environment? Explain the techniques and tools you use.
๐ Python Questions
1. How would you use Python to automate data extraction from various APIs and combine the data for analysis? Provide an example.
2. Describe a machine learning project you worked on using Python. What was the objective, and how did you approach the data preprocessing, model selection, and evaluation?
3. Explain how you would use Python to detect and handle anomalies in a dataset. What techniques and libraries would you employ?
๐ Power BI Questions
1. How do you create interactive dashboards in Power BI that can dynamically update based on user inputs? Provide an example of a dashboard you built.
2. Describe a scenario where you used Power BI to integrate data from non-traditional sources (e.g., web scraping, APIs). How did you handle the data transformation and visualization?
3. How do you ensure the performance and scalability of Power BI reports when dealing with large datasets? Describe the techniques and best practices you follow.
๐ก Tips for Success:
Understand the business context: Tailor your answers to show how your technical skills solve real business problems.
Provide specific examples: Highlight your past experiences with concrete examples.
Stay updated: Continuously learn and adapt to new tools and methodologies.
I have curated best 80+ top-notch Data Analytics Resources ๐๐
https://whatsapp.com/channel/0029VaGgzAk72WTmQFERKh02
Hope it helps :)
๐ Excel Questions
1. How do you use Excel to forecast future trends based on historical data? Describe a scenario where you built a forecasting model.
2. Can you explain how you would automate repetitive tasks in Excel using VBA (Visual Basic for Applications)? Provide an example of a complex macro you created.
3. Describe a time when you had to merge and analyze data from multiple Excel workbooks. How did you ensure data integrity and accuracy?
๐ SQL Questions
1. How would you design a database schema for a new e-commerce platform to efficiently handle large volumes of transactions and user data?
2. Describe a complex SQL query you wrote to solve a business problem. What was the problem, and how did your query help resolve it?
3. How do you ensure data integrity and consistency in a multi-user database environment? Explain the techniques and tools you use.
๐ Python Questions
1. How would you use Python to automate data extraction from various APIs and combine the data for analysis? Provide an example.
2. Describe a machine learning project you worked on using Python. What was the objective, and how did you approach the data preprocessing, model selection, and evaluation?
3. Explain how you would use Python to detect and handle anomalies in a dataset. What techniques and libraries would you employ?
๐ Power BI Questions
1. How do you create interactive dashboards in Power BI that can dynamically update based on user inputs? Provide an example of a dashboard you built.
2. Describe a scenario where you used Power BI to integrate data from non-traditional sources (e.g., web scraping, APIs). How did you handle the data transformation and visualization?
3. How do you ensure the performance and scalability of Power BI reports when dealing with large datasets? Describe the techniques and best practices you follow.
๐ก Tips for Success:
Understand the business context: Tailor your answers to show how your technical skills solve real business problems.
Provide specific examples: Highlight your past experiences with concrete examples.
Stay updated: Continuously learn and adapt to new tools and methodologies.
I have curated best 80+ top-notch Data Analytics Resources ๐๐
https://whatsapp.com/channel/0029VaGgzAk72WTmQFERKh02
Hope it helps :)
๐6
SQL Joins โ Essential Concepts ๐
1๏ธโฃ What Are SQL Joins?
SQL Joins are used to combine rows from two or more tables based on a related column.
2๏ธโฃ Types of Joins
INNER JOIN: Returns only matching rows from both tables.
SELECT * FROM TableA INNER JOIN TableB ON TableA.id = TableB.id;
LEFT JOIN (LEFT OUTER JOIN): Returns all rows from the left table and matching rows from the right table.
SELECT * FROM TableA LEFT JOIN TableB ON TableA.id = TableB.id;
RIGHT JOIN (RIGHT OUTER JOIN): Returns all rows from the right table and matching rows from the left table.
SELECT * FROM TableA RIGHT JOIN TableB ON TableA.id = TableB.id;
FULL JOIN (FULL OUTER JOIN): Returns all rows when there is a match in either table.
SELECT * FROM TableA FULL JOIN TableB ON TableA.id = TableB.id;
3๏ธโฃ Self Join
A table joins with itself to compare rows.
SELECT A.name, B.name FROM Employees A JOIN Employees B ON A.manager_id = B.id;
4๏ธโฃ Cross Join
Returns the Cartesian product of both tables (every row from Table A pairs with every row from Table B).
SELECT * FROM TableA CROSS JOIN TableB;
5๏ธโฃ Joins with Multiple Conditions
Using multiple columns for matching.
SELECT * FROM TableA INNER JOIN TableB ON TableA.id = TableB.id AND TableA.type = TableB.type;
6๏ธโฃ Using Aliases in Joins
Shortens table names for better readability.
SELECT A.name, B.salary FROM Employees A INNER JOIN Salaries B ON A.id = B.emp_id;
7๏ธโฃ Handling NULLs in Joins
Use COALESCE(column, default_value) to replace NULL values.
IS NULL to filter unmatched rows in LEFT or RIGHT JOINs.
Free SQL Resources: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
React with โค๏ธ for free resources
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
1๏ธโฃ What Are SQL Joins?
SQL Joins are used to combine rows from two or more tables based on a related column.
2๏ธโฃ Types of Joins
INNER JOIN: Returns only matching rows from both tables.
SELECT * FROM TableA INNER JOIN TableB ON TableA.id = TableB.id;
LEFT JOIN (LEFT OUTER JOIN): Returns all rows from the left table and matching rows from the right table.
SELECT * FROM TableA LEFT JOIN TableB ON TableA.id = TableB.id;
RIGHT JOIN (RIGHT OUTER JOIN): Returns all rows from the right table and matching rows from the left table.
SELECT * FROM TableA RIGHT JOIN TableB ON TableA.id = TableB.id;
FULL JOIN (FULL OUTER JOIN): Returns all rows when there is a match in either table.
SELECT * FROM TableA FULL JOIN TableB ON TableA.id = TableB.id;
3๏ธโฃ Self Join
A table joins with itself to compare rows.
SELECT A.name, B.name FROM Employees A JOIN Employees B ON A.manager_id = B.id;
4๏ธโฃ Cross Join
Returns the Cartesian product of both tables (every row from Table A pairs with every row from Table B).
SELECT * FROM TableA CROSS JOIN TableB;
5๏ธโฃ Joins with Multiple Conditions
Using multiple columns for matching.
SELECT * FROM TableA INNER JOIN TableB ON TableA.id = TableB.id AND TableA.type = TableB.type;
6๏ธโฃ Using Aliases in Joins
Shortens table names for better readability.
SELECT A.name, B.salary FROM Employees A INNER JOIN Salaries B ON A.id = B.emp_id;
7๏ธโฃ Handling NULLs in Joins
Use COALESCE(column, default_value) to replace NULL values.
IS NULL to filter unmatched rows in LEFT or RIGHT JOINs.
Free SQL Resources: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
React with โค๏ธ for free resources
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
๐6๐1
Complete SQL Topics for Data Analysts ๐๐
1. Introduction to SQL:
- Basic syntax and structure
- Understanding databases and tables
2. Querying Data:
- SELECT statement
- Filtering data using WHERE clause
- Sorting data with ORDER BY
3. Joins:
- INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN
- Combining data from multiple tables
4. Aggregation Functions:
- GROUP BY
- Aggregate functions like COUNT, SUM, AVG, MAX, MIN
5. Subqueries:
- Using subqueries in SELECT, WHERE, and HAVING clauses
6. Data Modification:
- INSERT, UPDATE, DELETE statements
- Transactions and Rollback
7. Data Types and Constraints:
- Understanding various data types (e.g., INT, VARCHAR)
- Using constraints (e.g., PRIMARY KEY, FOREIGN KEY)
8. Indexes:
- Creating and managing indexes for performance optimization
9. Views:
- Creating and using views for simplified querying
10. Stored Procedures and Functions:
- Writing and executing stored procedures
- Creating and using functions
11. Normalization:
- Understanding database normalization concepts
12. Data Import and Export:
- Importing and exporting data using SQL
13. Window Functions:
- ROW_NUMBER(), RANK(), DENSE_RANK(), and others
14. Advanced Filtering:
- Using CASE statements for conditional logic
15. Advanced Join Techniques:
- Self-joins and other advanced join scenarios
16. Analytical Functions:
- LAG(), LEAD(), OVER() for advanced analytics
17. Working with Dates and Times:
- Date and time functions and formatting
18. Performance Tuning:
- Query optimization strategies
19. Security:
- Understanding SQL injection and best practices for security
20. Handling NULL Values:
- Dealing with NULL values in queries
Ensure hands-on practice on these topics to strengthen your SQL skills.
Since SQL is one of the most essential skill for data analysts, I have decided to teach each topic daily in this channel for free. Like this post if you want me to continue this SQL series ๐โฅ๏ธ
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
1. Introduction to SQL:
- Basic syntax and structure
- Understanding databases and tables
2. Querying Data:
- SELECT statement
- Filtering data using WHERE clause
- Sorting data with ORDER BY
3. Joins:
- INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN
- Combining data from multiple tables
4. Aggregation Functions:
- GROUP BY
- Aggregate functions like COUNT, SUM, AVG, MAX, MIN
5. Subqueries:
- Using subqueries in SELECT, WHERE, and HAVING clauses
6. Data Modification:
- INSERT, UPDATE, DELETE statements
- Transactions and Rollback
7. Data Types and Constraints:
- Understanding various data types (e.g., INT, VARCHAR)
- Using constraints (e.g., PRIMARY KEY, FOREIGN KEY)
8. Indexes:
- Creating and managing indexes for performance optimization
9. Views:
- Creating and using views for simplified querying
10. Stored Procedures and Functions:
- Writing and executing stored procedures
- Creating and using functions
11. Normalization:
- Understanding database normalization concepts
12. Data Import and Export:
- Importing and exporting data using SQL
13. Window Functions:
- ROW_NUMBER(), RANK(), DENSE_RANK(), and others
14. Advanced Filtering:
- Using CASE statements for conditional logic
15. Advanced Join Techniques:
- Self-joins and other advanced join scenarios
16. Analytical Functions:
- LAG(), LEAD(), OVER() for advanced analytics
17. Working with Dates and Times:
- Date and time functions and formatting
18. Performance Tuning:
- Query optimization strategies
19. Security:
- Understanding SQL injection and best practices for security
20. Handling NULL Values:
- Dealing with NULL values in queries
Ensure hands-on practice on these topics to strengthen your SQL skills.
Since SQL is one of the most essential skill for data analysts, I have decided to teach each topic daily in this channel for free. Like this post if you want me to continue this SQL series ๐โฅ๏ธ
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
๐10โค1