Key Differences:
1- WHERE vs. HAVING
2- UNION vs. UNION ALL
3-INNER JOIN vs. LEFT JOIN vs. RIGHT JOIN vs. FULL JOIN
4-RANK() vs. DENSE_RANK() vs. ROW_NUMBER()
5-EXCEPT (MINUS) vs. INTERSECT
6-Subqueries vs. CTEs
7-JOINs vs. Subqueries
8-Aggregate functions with GROUP BY vs. Window functions
9-Temporary Table vs Table Variable
10-COALESCE vs. ISNULL
11-CHAR vs. VARCHAR
12-DELETE vs. TRUNCATE vs. DROP
13-Stored Procedures vs. User-Defined Functions
14- VIEWs vs MATERLIZED VIEW
15- PRIMARY KEY vs UNIQUE KEY
Real-World SQL Questions and Scenarios for your practice.
1-Find the top 5 customers with the highest average order value in the
last quarter.
2-Identify customers who have made purchases in consecutive months.
3- Calculate the month-over-month growth rate of sales revenue.
4- Identify duplicate records in a table and remove them.
5- Find nth Highest Salary.
6- Find the employee who have salary more than his manager.
7- Find the customers who have placed orders in both 2022 and 2023.
8-Calculate the running total of sales for each product category.
9- Retrieve the first order date for each customer.
10- List all customers who have made more than 3 orders.
11- Find the customers who have the same last name.
12- Create a query to find the top 3 products in each category by sales.
Some Basic STRING & DATE functions related questions:
1-Extract the month from a date column.
2- Convert a string date to a date format.
3-Replace all null values in a column with a specific value.
4-Concatenate two string columns.
5-Split a comma separated string into individual values.
6-Find the longest string in a column.
7-Create a query to find the percentage of total sales for each product.
8- Find the average time between customer orders.
9- Identify customers who have churned (not placed an order in the last 6
months).
10-Find the number of customers who joined each month/Quarter etc.