SQL Essential Concepts
๐ญ. ๐๐ป๐๐ฟ๐ผ ๐๐ผ ๐ฆ๐ค๐: Definition, purpose, relational DBs, DBMS.
๐ฎ. ๐๐ฎ๐๐ถ๐ฐ ๐ฆ๐ค๐ ๐ฆ๐๐ป๐๐ฎ๐ : SELECT, FROM, WHERE, ORDER BY, GROUP BY.
๐ฏ. ๐๐ฎ๐๐ฎ ๐ง๐๐ฝ๐ฒ๐: Integer, floating-point, character, date, VARCHAR, TEXT, BLOB, BOOLEAN.
๐ฐ. ๐ฆ๐๐ฏ ๐น๐ฎ๐ป๐ด๐๐ฎ๐ด๐ฒ๐: DML, DDL, DQL, DCL, TCL.
๐ฑ. ๐๐ฎ๐๐ฎ ๐ ๐ฎ๐ป๐ถ๐ฝ๐๐น๐ฎ๐๐ถ๐ผ๐ป: INSERT, UPDATE, DELETE.
๐ฒ. ๐๐ฎ๐๐ฎ ๐๐ฒ๐ณ๐ถ๐ป๐ถ๐๐ถ๐ผ๐ป: CREATE, ALTER, DROP, Indexes.
๐ณ. ๐ค๐๐ฒ๐ฟ๐ ๐๐ถ๐น๐๐ฒ๐ฟ๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐ฆ๐ผ๐ฟ๐๐ถ๐ป๐ด: WHERE, AND, OR conditions, ascending, descending.
๐ด. ๐๐ฎ๐๐ฎ ๐๐ด๐ด๐ฟ๐ฒ๐ด๐ฎ๐๐ถ๐ผ๐ป: SUM, AVG, COUNT, MIN, MAX.
๐ต. ๐๐ผ๐ถ๐ป๐ ๐ฎ๐ป๐ฑ ๐ฅ๐ฒ๐น๐ฎ๐๐ถ๐ผ๐ป๐๐ต๐ถ๐ฝ๐: INNER JOIN, LEFT JOIN, RIGHT JOIN, Self-Joins, Cross Joins, FULL OUTER JOIN.
๐ญ๐ฌ. ๐ฆ๐๐ฏ๐พ๐๐ฒ๐ฟ๐ถ๐ฒ๐: Filtering data, aggregating data, joining tables, correlated subqueries.
๐ญ๐ญ. ๐ฉ๐ถ๐ฒ๐๐: Creating, modifying, dropping views.
๐ญ๐ฎ. ๐ง๐ฟ๐ฎ๐ป๐๐ฎ๐ฐ๐๐ถ๐ผ๐ป๐: ACID properties, COMMIT, ROLLBACK, SAVEPOINT, ROLLBACK TO SAVEPOINT.
๐ญ๐ฏ. ๐ฆ๐๐ผ๐ฟ๐ฒ๐ฑ ๐ฃ๐ฟ๐ผ๐ฐ๐ฒ๐ฑ๐๐ฟ๐ฒ๐: CREATE, ALTER, DROP, EXECUTE, User-Defined Functions (UDFs).
๐ญ๐ฐ. ๐ง๐ฟ๐ถ๐ด๐ด๐ฒ๐ฟ๐: Trigger events, trigger execution, and syntax.
๐ญ๐ฑ. ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ ๐ฎ๐ป๐ฑ ๐ฃ๐ฒ๐ฟ๐บ๐ถ๐๐๐ถ๐ผ๐ป๐: CREATE USER, GRANT, REVOKE, ALTER USER, DROP USER.
๐ญ๐ฒ. ๐ข๐ฝ๐๐ถ๐บ๐ถ๐๐ฎ๐๐ถ๐ผ๐ป๐: Indexing strategies, query optimization.
๐ญ๐ณ. ๐ก๐ผ๐ฟ๐บ๐ฎ๐น๐ถ๐๐ฎ๐๐ถ๐ผ๐ป: 1NF, 2NF, 3NF, BCNF.
๐ญ๐ด. ๐ก๐ผ๐ฆ๐ค๐ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ๐: MongoDB, Cassandra, and key differences.
๐ญ๐ต. ๐๐ฎ๐๐ฎ ๐๐ป๐๐ฒ๐ด๐ฟ๐ถ๐๐: Primary key, foreign key.
๐ฎ๐ฌ. ๐๐ฑ๐๐ฎ๐ป๐ฐ๐ฒ๐ฑ ๐ฆ๐ค๐ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐: Window functions, Common Table Expressions (CTES).
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
#sql
๐ญ. ๐๐ป๐๐ฟ๐ผ ๐๐ผ ๐ฆ๐ค๐: Definition, purpose, relational DBs, DBMS.
๐ฎ. ๐๐ฎ๐๐ถ๐ฐ ๐ฆ๐ค๐ ๐ฆ๐๐ป๐๐ฎ๐ : SELECT, FROM, WHERE, ORDER BY, GROUP BY.
๐ฏ. ๐๐ฎ๐๐ฎ ๐ง๐๐ฝ๐ฒ๐: Integer, floating-point, character, date, VARCHAR, TEXT, BLOB, BOOLEAN.
๐ฐ. ๐ฆ๐๐ฏ ๐น๐ฎ๐ป๐ด๐๐ฎ๐ด๐ฒ๐: DML, DDL, DQL, DCL, TCL.
๐ฑ. ๐๐ฎ๐๐ฎ ๐ ๐ฎ๐ป๐ถ๐ฝ๐๐น๐ฎ๐๐ถ๐ผ๐ป: INSERT, UPDATE, DELETE.
๐ฒ. ๐๐ฎ๐๐ฎ ๐๐ฒ๐ณ๐ถ๐ป๐ถ๐๐ถ๐ผ๐ป: CREATE, ALTER, DROP, Indexes.
๐ณ. ๐ค๐๐ฒ๐ฟ๐ ๐๐ถ๐น๐๐ฒ๐ฟ๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐ฆ๐ผ๐ฟ๐๐ถ๐ป๐ด: WHERE, AND, OR conditions, ascending, descending.
๐ด. ๐๐ฎ๐๐ฎ ๐๐ด๐ด๐ฟ๐ฒ๐ด๐ฎ๐๐ถ๐ผ๐ป: SUM, AVG, COUNT, MIN, MAX.
๐ต. ๐๐ผ๐ถ๐ป๐ ๐ฎ๐ป๐ฑ ๐ฅ๐ฒ๐น๐ฎ๐๐ถ๐ผ๐ป๐๐ต๐ถ๐ฝ๐: INNER JOIN, LEFT JOIN, RIGHT JOIN, Self-Joins, Cross Joins, FULL OUTER JOIN.
๐ญ๐ฌ. ๐ฆ๐๐ฏ๐พ๐๐ฒ๐ฟ๐ถ๐ฒ๐: Filtering data, aggregating data, joining tables, correlated subqueries.
๐ญ๐ญ. ๐ฉ๐ถ๐ฒ๐๐: Creating, modifying, dropping views.
๐ญ๐ฎ. ๐ง๐ฟ๐ฎ๐ป๐๐ฎ๐ฐ๐๐ถ๐ผ๐ป๐: ACID properties, COMMIT, ROLLBACK, SAVEPOINT, ROLLBACK TO SAVEPOINT.
๐ญ๐ฏ. ๐ฆ๐๐ผ๐ฟ๐ฒ๐ฑ ๐ฃ๐ฟ๐ผ๐ฐ๐ฒ๐ฑ๐๐ฟ๐ฒ๐: CREATE, ALTER, DROP, EXECUTE, User-Defined Functions (UDFs).
๐ญ๐ฐ. ๐ง๐ฟ๐ถ๐ด๐ด๐ฒ๐ฟ๐: Trigger events, trigger execution, and syntax.
๐ญ๐ฑ. ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ ๐ฎ๐ป๐ฑ ๐ฃ๐ฒ๐ฟ๐บ๐ถ๐๐๐ถ๐ผ๐ป๐: CREATE USER, GRANT, REVOKE, ALTER USER, DROP USER.
๐ญ๐ฒ. ๐ข๐ฝ๐๐ถ๐บ๐ถ๐๐ฎ๐๐ถ๐ผ๐ป๐: Indexing strategies, query optimization.
๐ญ๐ณ. ๐ก๐ผ๐ฟ๐บ๐ฎ๐น๐ถ๐๐ฎ๐๐ถ๐ผ๐ป: 1NF, 2NF, 3NF, BCNF.
๐ญ๐ด. ๐ก๐ผ๐ฆ๐ค๐ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ๐: MongoDB, Cassandra, and key differences.
๐ญ๐ต. ๐๐ฎ๐๐ฎ ๐๐ป๐๐ฒ๐ด๐ฟ๐ถ๐๐: Primary key, foreign key.
๐ฎ๐ฌ. ๐๐ฑ๐๐ฎ๐ป๐ฐ๐ฒ๐ฑ ๐ฆ๐ค๐ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐: Window functions, Common Table Expressions (CTES).
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
#sql
๐8โค1
SQL queries that are commonly asked during interviews: 3.O .............
1. Find employees who report to a specific manager:
SELECT employee_id, employee_name
FROM Employee
WHERE manager_id = 101; -- Replace 101 with the specific manager_id;
2. Get the top 3 highest paid employees:
SELECT employee_id, salary
FROM Employee
ORDER BY salary DESC
LIMIT 3;
3. Find products with sales above the average sales:
SELECT product_id, SUM(sales_amount) AS total_sales
FROM Sales
GROUP BY product_id
HAVING total_sales > (SELECT AVG(sales_amount) FROM Sales);
4. Retrieve customers who placed orders within a specific date range:
SELECT customer_id, order_id
FROM Orders
WHERE order_date BETWEEN '2024-01-01' AND '2024-12-31'; -- Replace with your date range
5. Find departments with more than 5 employees:
SELECT department, COUNT(employee_id) AS total_employees
FROM Employee
GROUP BY department
HAVING COUNT(employee_id) > 5;
6. Calculate the average order value for each customer:
SELECT customer_id, AVG(total_amount) AS average_order_value
FROM Orders
GROUP BY customer_id;
7. List products that have been sold at least 5 times:
SELECT product_id, COUNT(order_id) AS times_sold
FROM Sales
GROUP BY product_id
HAVING COUNT(order_id) >= 5;
8. Get the total number of orders placed by each customer per year:
SELECT customer_id, YEAR(order_date) AS year, COUNT(order_id) AS total_orders
FROM Orders
GROUP BY customer_id, YEAR(order_date);
9. Retrieve employees who have worked for more than 5 years:
SELECT employee_id, employee_name
FROM Employee
WHERE DATEDIFF(YEAR, hire_date, GETDATE()) > 5;
10. Find the department with the highest total salary:
SELECT department, SUM(salary) AS total_salary
FROM Employee
GROUP BY department
ORDER BY total_salary DESC
LIMIT 1;
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
1. Find employees who report to a specific manager:
SELECT employee_id, employee_name
FROM Employee
WHERE manager_id = 101; -- Replace 101 with the specific manager_id;
2. Get the top 3 highest paid employees:
SELECT employee_id, salary
FROM Employee
ORDER BY salary DESC
LIMIT 3;
3. Find products with sales above the average sales:
SELECT product_id, SUM(sales_amount) AS total_sales
FROM Sales
GROUP BY product_id
HAVING total_sales > (SELECT AVG(sales_amount) FROM Sales);
4. Retrieve customers who placed orders within a specific date range:
SELECT customer_id, order_id
FROM Orders
WHERE order_date BETWEEN '2024-01-01' AND '2024-12-31'; -- Replace with your date range
5. Find departments with more than 5 employees:
SELECT department, COUNT(employee_id) AS total_employees
FROM Employee
GROUP BY department
HAVING COUNT(employee_id) > 5;
6. Calculate the average order value for each customer:
SELECT customer_id, AVG(total_amount) AS average_order_value
FROM Orders
GROUP BY customer_id;
7. List products that have been sold at least 5 times:
SELECT product_id, COUNT(order_id) AS times_sold
FROM Sales
GROUP BY product_id
HAVING COUNT(order_id) >= 5;
8. Get the total number of orders placed by each customer per year:
SELECT customer_id, YEAR(order_date) AS year, COUNT(order_id) AS total_orders
FROM Orders
GROUP BY customer_id, YEAR(order_date);
9. Retrieve employees who have worked for more than 5 years:
SELECT employee_id, employee_name
FROM Employee
WHERE DATEDIFF(YEAR, hire_date, GETDATE()) > 5;
10. Find the department with the highest total salary:
SELECT department, SUM(salary) AS total_salary
FROM Employee
GROUP BY department
ORDER BY total_salary DESC
LIMIT 1;
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐2
Top 5 SQL Functions
1. SELECT Statement:
- Function: Retrieving data from one or more tables.
- Example:
2. COUNT Function:
- Function: Counts the number of rows that meet a specified condition.
- Example:
3. SUM Function:
- Function: Calculates the sum of values in a numeric column.
- Example:
4. AVG Function:
- Function: Computes the average value of a numeric column.
- Example:
5. GROUP BY Clause:
- Function: Groups rows that have the same values in specified columns into summary rows.
- Example:
Here you can find essential SQL Interview Resources: t.iss.one/mysqldata
Like this post if you need more ๐โค๏ธ
Hope it helps :)
1. SELECT Statement:
- Function: Retrieving data from one or more tables.
- Example:
SELECT column1, column2 FROM table WHERE condition;2. COUNT Function:
- Function: Counts the number of rows that meet a specified condition.
- Example:
SELECT COUNT(column) FROM table WHERE condition;3. SUM Function:
- Function: Calculates the sum of values in a numeric column.
- Example:
SELECT SUM(column) FROM table WHERE condition;4. AVG Function:
- Function: Computes the average value of a numeric column.
- Example:
SELECT AVG(column) FROM table WHERE condition;5. GROUP BY Clause:
- Function: Groups rows that have the same values in specified columns into summary rows.
- Example:
SELECT column, AVG(numeric_column) FROM table GROUP BY column;Here you can find essential SQL Interview Resources: t.iss.one/mysqldata
Like this post if you need more ๐โค๏ธ
Hope it helps :)
โค4๐1
Essential SQL interview questions covering various topics:
๐บBasic SQL Concepts:
-Differentiate between SQL and NoSQL databases.
-List common data types in SQL.
๐บQuerying:
-Retrieve all records from a table named "Customers."
-Contrast SELECT and SELECT DISTINCT.
-Explain the purpose of the WHERE clause.
๐บJoins:
-Describe types of joins (INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN).
-Retrieve data from two tables using INNER JOIN.
๐บAggregate Functions:
-Define aggregate functions and name a few.
-Calculate average, sum, and count of a column in SQL.
๐บGrouping and Filtering:
-Explain the GROUP BY clause and its use.
-Filter SQL query results using the HAVING clause.
๐บSubqueries:
-Define a subquery and provide an example.
๐บIndexes and Optimization:
-Discuss the importance of indexes in a database.
&Optimize a slow-running SQL query.
๐บNormalization and Data Integrity:
-Define database normalization and its significance.
-Enforce data integrity in a SQL database.
๐บTransactions:
-Define a SQL transaction and its purpose.
-Explain ACID properties in database transactions.
๐บViews and Stored Procedures:
-Define a database view and its use.
-Distinguish a stored procedure from a regular SQL query.
๐บAdvanced SQL:
-Write a recursive SQL query and explain its use.
-Explain window functions in SQL.
โ ๐These questions offer a comprehensive assessment of SQL knowledge, ranging from basics to advanced concepts.
โค๏ธLike if you'd like answers in the next post! ๐
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐บBasic SQL Concepts:
-Differentiate between SQL and NoSQL databases.
-List common data types in SQL.
๐บQuerying:
-Retrieve all records from a table named "Customers."
-Contrast SELECT and SELECT DISTINCT.
-Explain the purpose of the WHERE clause.
๐บJoins:
-Describe types of joins (INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN).
-Retrieve data from two tables using INNER JOIN.
๐บAggregate Functions:
-Define aggregate functions and name a few.
-Calculate average, sum, and count of a column in SQL.
๐บGrouping and Filtering:
-Explain the GROUP BY clause and its use.
-Filter SQL query results using the HAVING clause.
๐บSubqueries:
-Define a subquery and provide an example.
๐บIndexes and Optimization:
-Discuss the importance of indexes in a database.
&Optimize a slow-running SQL query.
๐บNormalization and Data Integrity:
-Define database normalization and its significance.
-Enforce data integrity in a SQL database.
๐บTransactions:
-Define a SQL transaction and its purpose.
-Explain ACID properties in database transactions.
๐บViews and Stored Procedures:
-Define a database view and its use.
-Distinguish a stored procedure from a regular SQL query.
๐บAdvanced SQL:
-Write a recursive SQL query and explain its use.
-Explain window functions in SQL.
โ ๐These questions offer a comprehensive assessment of SQL knowledge, ranging from basics to advanced concepts.
โค๏ธLike if you'd like answers in the next post! ๐
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐5
Here are few Important SQL interview questions with topics
Basic SQL Concepts:
Explain the difference between SQL and NoSQL databases.
What are the common data types in SQL?
Querying:
How do you retrieve all records from a table named "Customers"?
What is the difference between SELECT and SELECT DISTINCT in a query?
Explain the purpose of the WHERE clause in SQL queries.
Joins:
Describe the types of joins in SQL (INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN).
How would you retrieve data from two tables using an INNER JOIN?
Aggregate Functions:
What are aggregate functions in SQL? Can you name a few?
How do you calculate the average, sum, and count of a column in a SQL query?
Grouping and Filtering:
Explain the GROUP BY clause and its use in SQL.
How would you filter the results of an SQL query using the HAVING clause?
Subqueries:
What is a subquery, and when would you use one in SQL?
Provide an example of a subquery in an SQL statement.
Indexes and Optimization:
Why are indexes important in a database?
How would you optimize a slow-running SQL query?
Normalization and Data Integrity:
What is database normalization, and why is it important?
How can you enforce data integrity in a SQL database?
Transactions:
What is a SQL transaction, and why would you use it?
Explain the concepts of ACID properties in database transactions.
Views and Stored Procedures:
What is a database view, and when would you create one?
What is a stored procedure, and how does it differ from a regular SQL query?
Advanced SQL:
Can you write a recursive SQL query, and when would you use recursion?
Explain the concept of window functions in SQL.
These questions cover a range of SQL topics, from basic concepts to more advanced techniques, and can help assess a candidate's knowledge and skills in SQL :)
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
Basic SQL Concepts:
Explain the difference between SQL and NoSQL databases.
What are the common data types in SQL?
Querying:
How do you retrieve all records from a table named "Customers"?
What is the difference between SELECT and SELECT DISTINCT in a query?
Explain the purpose of the WHERE clause in SQL queries.
Joins:
Describe the types of joins in SQL (INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN).
How would you retrieve data from two tables using an INNER JOIN?
Aggregate Functions:
What are aggregate functions in SQL? Can you name a few?
How do you calculate the average, sum, and count of a column in a SQL query?
Grouping and Filtering:
Explain the GROUP BY clause and its use in SQL.
How would you filter the results of an SQL query using the HAVING clause?
Subqueries:
What is a subquery, and when would you use one in SQL?
Provide an example of a subquery in an SQL statement.
Indexes and Optimization:
Why are indexes important in a database?
How would you optimize a slow-running SQL query?
Normalization and Data Integrity:
What is database normalization, and why is it important?
How can you enforce data integrity in a SQL database?
Transactions:
What is a SQL transaction, and why would you use it?
Explain the concepts of ACID properties in database transactions.
Views and Stored Procedures:
What is a database view, and when would you create one?
What is a stored procedure, and how does it differ from a regular SQL query?
Advanced SQL:
Can you write a recursive SQL query, and when would you use recursion?
Explain the concept of window functions in SQL.
These questions cover a range of SQL topics, from basic concepts to more advanced techniques, and can help assess a candidate's knowledge and skills in SQL :)
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐2
๐ข๐ฟ๐ฑ๐ฒ๐ฟ ๐ข๐ณ ๐๐
๐ฒ๐ฐ๐๐๐ถ๐ผ๐ป in SQL โ
1 โ FROM (Tables selected).
2 โ WHERE (Filters applied).
3 โ GROUP BY (Rows grouped).
4 โ HAVING (Filter on grouped data).
5 โ SELECT (Columns selected).
6 โ ORDER BY (Sort the data).
7 โ LIMIT (Restrict number of rows).
๐๐ผ๐บ๐บ๐ผ๐ป ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐ ๐ง๐ผ ๐ฃ๐ฟ๐ฎ๐ฐ๐๐ถ๐ฐ๐ฒ โ
โฌ Find the second-highest salary:
SELECT MAX(Salary) FROM Employees WHERE Salary < (SELECT MAX(Salary) FROM Employees);
โฌ Find duplicate records:
SELECT Name, COUNT(*)
FROM Emp
GROUP BY Name
HAVING COUNT(*) > 1;
1 โ FROM (Tables selected).
2 โ WHERE (Filters applied).
3 โ GROUP BY (Rows grouped).
4 โ HAVING (Filter on grouped data).
5 โ SELECT (Columns selected).
6 โ ORDER BY (Sort the data).
7 โ LIMIT (Restrict number of rows).
๐๐ผ๐บ๐บ๐ผ๐ป ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐ ๐ง๐ผ ๐ฃ๐ฟ๐ฎ๐ฐ๐๐ถ๐ฐ๐ฒ โ
โฌ Find the second-highest salary:
SELECT MAX(Salary) FROM Employees WHERE Salary < (SELECT MAX(Salary) FROM Employees);
โฌ Find duplicate records:
SELECT Name, COUNT(*)
FROM Emp
GROUP BY Name
HAVING COUNT(*) > 1;
๐10โค1
Here are some essential SQL tips for beginners ๐๐
โ Primary Key = Unique Key + Not Null constraint
โ To perform case insensitive search use UPPER() function ex. UPPER(customer_name) LIKE โA%Aโ
โ LIKE operator is for string data type
โ COUNT(*), COUNT(1), COUNT(0) all are same
โ All aggregate functions ignore the NULL values
โ Aggregate functions MIN, MAX, SUM, AVG, COUNT are for int data type whereas STRING_AGG is for string data type
โ For row level filtration use WHERE and aggregate level filtration use HAVING
โ UNION ALL will include duplicates where as UNION excludes duplicates
โ If the results will not have any duplicates, use UNION ALL instead of UNION
โ We have to alias the subquery if we are using the columns in the outer select query
โ Subqueries can be used as output with NOT IN condition.
โ CTEs look better than subqueries. Performance wise both are same.
โ When joining two tables , if one table has only one value then we can use 1=1 as a condition to join the tables. This will be considered as CROSS JOIN.
โ Window functions work at ROW level.
โ The difference between RANK() and DENSE_RANK() is that RANK() skips the rank if the values are the same.
โ EXISTS works on true/false conditions. If the query returns at least one value, the condition is TRUE. All the records corresponding to the conditions are returned.
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
โ Primary Key = Unique Key + Not Null constraint
โ To perform case insensitive search use UPPER() function ex. UPPER(customer_name) LIKE โA%Aโ
โ LIKE operator is for string data type
โ COUNT(*), COUNT(1), COUNT(0) all are same
โ All aggregate functions ignore the NULL values
โ Aggregate functions MIN, MAX, SUM, AVG, COUNT are for int data type whereas STRING_AGG is for string data type
โ For row level filtration use WHERE and aggregate level filtration use HAVING
โ UNION ALL will include duplicates where as UNION excludes duplicates
โ If the results will not have any duplicates, use UNION ALL instead of UNION
โ We have to alias the subquery if we are using the columns in the outer select query
โ Subqueries can be used as output with NOT IN condition.
โ CTEs look better than subqueries. Performance wise both are same.
โ When joining two tables , if one table has only one value then we can use 1=1 as a condition to join the tables. This will be considered as CROSS JOIN.
โ Window functions work at ROW level.
โ The difference between RANK() and DENSE_RANK() is that RANK() skips the rank if the values are the same.
โ EXISTS works on true/false conditions. If the query returns at least one value, the condition is TRUE. All the records corresponding to the conditions are returned.
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐5๐4
Did you know how NULL values are treated in GROUP BY?
In SQL, when you use GROUP BY, all NULL values in a column are grouped together, as if they were one single value.
This can be surprising because, outside of GROUP BY, SQL treats NULL as an unknown, meaning that NULL = NULL is false!
Here's an example:
SELECT department, COUNT(*) FROM employees GROUPBY department;
If some department values are NULL, SQL groups all those NULL entries together. This is helpful for aggregation, but it can also lead to unexpected results if you're not aware of it.
This behavior is unique to GROUP BY and highlights SQLโs different handling of NULL depending on context. So next time youโre aggregating, donโt forget to consider those NULLs!
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
In SQL, when you use GROUP BY, all NULL values in a column are grouped together, as if they were one single value.
This can be surprising because, outside of GROUP BY, SQL treats NULL as an unknown, meaning that NULL = NULL is false!
Here's an example:
SELECT department, COUNT(*) FROM employees GROUPBY department;
If some department values are NULL, SQL groups all those NULL entries together. This is helpful for aggregation, but it can also lead to unexpected results if you're not aware of it.
This behavior is unique to GROUP BY and highlights SQLโs different handling of NULL depending on context. So next time youโre aggregating, donโt forget to consider those NULLs!
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐1
๐๐ผ ๐๐ผ๐ ๐๐ฎ๐ป๐ ๐๐ผ ๐ฆ๐๐๐ฑ๐ ๐๐ฏ๐ฟ๐ผ๐ฎ๐ฑ ๐ฎ๐ป๐ฑ ๐ฑ๐ผ๐ปโ๐ ๐ธ๐ป๐ผ๐ ๐ต๐ผ๐ ๐๐ผ ๐๐๐ฎ๐ฟ๐ ๐๐ต๐ฒ๐ฟ๐ฒ ๐๐ผ ๐๐๐ฎ๐ฟ๐ ๐ณ๐ฟ๐ผ๐บ๐?
Guess what? I have one solution for all your problems.
Fateh education from choosing the right country, right university from navigating visa application and processing, personalised counselling, and accommodation and so much more.
Get the Right Guidance to Study Abroad
Fateh education is with you all along. Best part is that coming to your cities, are you ready to take the next step?
So join us at the admission day Event happening in Hyderabad on 9th march and 6th April and in Bangalore on 29th march.
So take the expert advice and register now for your dream career
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐ก๐ผ๐๐:-
https://bit.ly/4hbiHeF
( Limited Slots )
Guess what? I have one solution for all your problems.
Fateh education from choosing the right country, right university from navigating visa application and processing, personalised counselling, and accommodation and so much more.
Get the Right Guidance to Study Abroad
Fateh education is with you all along. Best part is that coming to your cities, are you ready to take the next step?
So join us at the admission day Event happening in Hyderabad on 9th march and 6th April and in Bangalore on 29th march.
So take the expert advice and register now for your dream career
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐ก๐ผ๐๐:-
https://bit.ly/4hbiHeF
( Limited Slots )
โค2
TOP CONCEPTS FOR INTERVIEW PREPARATION!!
๐TOP 10 SQL Concepts for Job Interview
1. Aggregate Functions (SUM/AVG)
2. Group By and Order By
3. JOINs (Inner/Left/Right)
4. Union and Union All
5. Date and Time processing
6. String processing
7. Window Functions (Partition by)
8. Subquery
9. View and Index
10. Common Table Expression (CTE)
๐TOP 10 Statistics Concepts for Job Interview
1. Sampling
2. Experiments (A/B tests)
3. Descriptive Statistics
4. p-value
5. Probability Distributions
6. t-test
7. ANOVA
8. Correlation
9. Linear Regression
10. Logistics Regression
๐TOP 10 Python Concepts for Job Interview
1. Reading data from file/table
2. Writing data to file/table
3. Data Types
4. Function
5. Data Preprocessing (numpy/pandas)
6. Data Visualisation (Matplotlib/seaborn/bokeh)
7. Machine Learning (sklearn)
8. Deep Learning (Tensorflow/Keras/PyTorch)
9. Distributed Processing (PySpark)
10. Functional and Object Oriented Programming
Like โค๏ธ the post if it was helpful to you!!!
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Hope it helps :)
๐TOP 10 SQL Concepts for Job Interview
1. Aggregate Functions (SUM/AVG)
2. Group By and Order By
3. JOINs (Inner/Left/Right)
4. Union and Union All
5. Date and Time processing
6. String processing
7. Window Functions (Partition by)
8. Subquery
9. View and Index
10. Common Table Expression (CTE)
๐TOP 10 Statistics Concepts for Job Interview
1. Sampling
2. Experiments (A/B tests)
3. Descriptive Statistics
4. p-value
5. Probability Distributions
6. t-test
7. ANOVA
8. Correlation
9. Linear Regression
10. Logistics Regression
๐TOP 10 Python Concepts for Job Interview
1. Reading data from file/table
2. Writing data to file/table
3. Data Types
4. Function
5. Data Preprocessing (numpy/pandas)
6. Data Visualisation (Matplotlib/seaborn/bokeh)
7. Machine Learning (sklearn)
8. Deep Learning (Tensorflow/Keras/PyTorch)
9. Distributed Processing (PySpark)
10. Functional and Object Oriented Programming
Like โค๏ธ the post if it was helpful to you!!!
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Hope it helps :)
โค5๐4
SQL Essential Concepts
๐ญ. ๐๐ป๐๐ฟ๐ผ ๐๐ผ ๐ฆ๐ค๐: Definition, purpose, relational DBs, DBMS.
๐ฎ. ๐๐ฎ๐๐ถ๐ฐ ๐ฆ๐ค๐ ๐ฆ๐๐ป๐๐ฎ๐ : SELECT, FROM, WHERE, ORDER BY, GROUP BY.
๐ฏ. ๐๐ฎ๐๐ฎ ๐ง๐๐ฝ๐ฒ๐: Integer, floating-point, character, date, VARCHAR, TEXT, BLOB, BOOLEAN.
๐ฐ. ๐ฆ๐๐ฏ ๐น๐ฎ๐ป๐ด๐๐ฎ๐ด๐ฒ๐: DML, DDL, DQL, DCL, TCL.
๐ฑ. ๐๐ฎ๐๐ฎ ๐ ๐ฎ๐ป๐ถ๐ฝ๐๐น๐ฎ๐๐ถ๐ผ๐ป: INSERT, UPDATE, DELETE.
๐ฒ. ๐๐ฎ๐๐ฎ ๐๐ฒ๐ณ๐ถ๐ป๐ถ๐๐ถ๐ผ๐ป: CREATE, ALTER, DROP, Indexes.
๐ณ. ๐ค๐๐ฒ๐ฟ๐ ๐๐ถ๐น๐๐ฒ๐ฟ๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐ฆ๐ผ๐ฟ๐๐ถ๐ป๐ด: WHERE, AND, OR conditions, ascending, descending.
๐ด. ๐๐ฎ๐๐ฎ ๐๐ด๐ด๐ฟ๐ฒ๐ด๐ฎ๐๐ถ๐ผ๐ป: SUM, AVG, COUNT, MIN, MAX.
๐ต. ๐๐ผ๐ถ๐ป๐ ๐ฎ๐ป๐ฑ ๐ฅ๐ฒ๐น๐ฎ๐๐ถ๐ผ๐ป๐๐ต๐ถ๐ฝ๐: INNER JOIN, LEFT JOIN, RIGHT JOIN, Self-Joins, Cross Joins, FULL OUTER JOIN.
๐ญ๐ฌ. ๐ฆ๐๐ฏ๐พ๐๐ฒ๐ฟ๐ถ๐ฒ๐: Filtering data, aggregating data, joining tables, correlated subqueries.
๐ญ๐ญ. ๐ฉ๐ถ๐ฒ๐๐: Creating, modifying, dropping views.
๐ญ๐ฎ. ๐ง๐ฟ๐ฎ๐ป๐๐ฎ๐ฐ๐๐ถ๐ผ๐ป๐: ACID properties, COMMIT, ROLLBACK, SAVEPOINT, ROLLBACK TO SAVEPOINT.
๐ญ๐ฏ. ๐ฆ๐๐ผ๐ฟ๐ฒ๐ฑ ๐ฃ๐ฟ๐ผ๐ฐ๐ฒ๐ฑ๐๐ฟ๐ฒ๐: CREATE, ALTER, DROP, EXECUTE, User-Defined Functions (UDFs).
๐ญ๐ฐ. ๐ง๐ฟ๐ถ๐ด๐ด๐ฒ๐ฟ๐: Trigger events, trigger execution, and syntax.
๐ญ๐ฑ. ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ ๐ฎ๐ป๐ฑ ๐ฃ๐ฒ๐ฟ๐บ๐ถ๐๐๐ถ๐ผ๐ป๐: CREATE USER, GRANT, REVOKE, ALTER USER, DROP USER.
๐ญ๐ฒ. ๐ข๐ฝ๐๐ถ๐บ๐ถ๐๐ฎ๐๐ถ๐ผ๐ป๐: Indexing strategies, query optimization.
๐ญ๐ณ. ๐ก๐ผ๐ฟ๐บ๐ฎ๐น๐ถ๐๐ฎ๐๐ถ๐ผ๐ป: 1NF, 2NF, 3NF, BCNF.
๐ญ๐ด. ๐ก๐ผ๐ฆ๐ค๐ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ๐: MongoDB, Cassandra, and key differences.
๐ญ๐ต. ๐๐ฎ๐๐ฎ ๐๐ป๐๐ฒ๐ด๐ฟ๐ถ๐๐: Primary key, foreign key.
๐ฎ๐ฌ. ๐๐ฑ๐๐ฎ๐ป๐ฐ๐ฒ๐ฑ ๐ฆ๐ค๐ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐: Window functions, Common Table Expressions (CTES).
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐ญ. ๐๐ป๐๐ฟ๐ผ ๐๐ผ ๐ฆ๐ค๐: Definition, purpose, relational DBs, DBMS.
๐ฎ. ๐๐ฎ๐๐ถ๐ฐ ๐ฆ๐ค๐ ๐ฆ๐๐ป๐๐ฎ๐ : SELECT, FROM, WHERE, ORDER BY, GROUP BY.
๐ฏ. ๐๐ฎ๐๐ฎ ๐ง๐๐ฝ๐ฒ๐: Integer, floating-point, character, date, VARCHAR, TEXT, BLOB, BOOLEAN.
๐ฐ. ๐ฆ๐๐ฏ ๐น๐ฎ๐ป๐ด๐๐ฎ๐ด๐ฒ๐: DML, DDL, DQL, DCL, TCL.
๐ฑ. ๐๐ฎ๐๐ฎ ๐ ๐ฎ๐ป๐ถ๐ฝ๐๐น๐ฎ๐๐ถ๐ผ๐ป: INSERT, UPDATE, DELETE.
๐ฒ. ๐๐ฎ๐๐ฎ ๐๐ฒ๐ณ๐ถ๐ป๐ถ๐๐ถ๐ผ๐ป: CREATE, ALTER, DROP, Indexes.
๐ณ. ๐ค๐๐ฒ๐ฟ๐ ๐๐ถ๐น๐๐ฒ๐ฟ๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐ฆ๐ผ๐ฟ๐๐ถ๐ป๐ด: WHERE, AND, OR conditions, ascending, descending.
๐ด. ๐๐ฎ๐๐ฎ ๐๐ด๐ด๐ฟ๐ฒ๐ด๐ฎ๐๐ถ๐ผ๐ป: SUM, AVG, COUNT, MIN, MAX.
๐ต. ๐๐ผ๐ถ๐ป๐ ๐ฎ๐ป๐ฑ ๐ฅ๐ฒ๐น๐ฎ๐๐ถ๐ผ๐ป๐๐ต๐ถ๐ฝ๐: INNER JOIN, LEFT JOIN, RIGHT JOIN, Self-Joins, Cross Joins, FULL OUTER JOIN.
๐ญ๐ฌ. ๐ฆ๐๐ฏ๐พ๐๐ฒ๐ฟ๐ถ๐ฒ๐: Filtering data, aggregating data, joining tables, correlated subqueries.
๐ญ๐ญ. ๐ฉ๐ถ๐ฒ๐๐: Creating, modifying, dropping views.
๐ญ๐ฎ. ๐ง๐ฟ๐ฎ๐ป๐๐ฎ๐ฐ๐๐ถ๐ผ๐ป๐: ACID properties, COMMIT, ROLLBACK, SAVEPOINT, ROLLBACK TO SAVEPOINT.
๐ญ๐ฏ. ๐ฆ๐๐ผ๐ฟ๐ฒ๐ฑ ๐ฃ๐ฟ๐ผ๐ฐ๐ฒ๐ฑ๐๐ฟ๐ฒ๐: CREATE, ALTER, DROP, EXECUTE, User-Defined Functions (UDFs).
๐ญ๐ฐ. ๐ง๐ฟ๐ถ๐ด๐ด๐ฒ๐ฟ๐: Trigger events, trigger execution, and syntax.
๐ญ๐ฑ. ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ ๐ฎ๐ป๐ฑ ๐ฃ๐ฒ๐ฟ๐บ๐ถ๐๐๐ถ๐ผ๐ป๐: CREATE USER, GRANT, REVOKE, ALTER USER, DROP USER.
๐ญ๐ฒ. ๐ข๐ฝ๐๐ถ๐บ๐ถ๐๐ฎ๐๐ถ๐ผ๐ป๐: Indexing strategies, query optimization.
๐ญ๐ณ. ๐ก๐ผ๐ฟ๐บ๐ฎ๐น๐ถ๐๐ฎ๐๐ถ๐ผ๐ป: 1NF, 2NF, 3NF, BCNF.
๐ญ๐ด. ๐ก๐ผ๐ฆ๐ค๐ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ๐: MongoDB, Cassandra, and key differences.
๐ญ๐ต. ๐๐ฎ๐๐ฎ ๐๐ป๐๐ฒ๐ด๐ฟ๐ถ๐๐: Primary key, foreign key.
๐ฎ๐ฌ. ๐๐ฑ๐๐ฎ๐ป๐ฐ๐ฒ๐ฑ ๐ฆ๐ค๐ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐: Window functions, Common Table Expressions (CTES).
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐7โค2
7โฃ SQL functions for data cleaning:
1. TRIM():
Usage: Removes leading and trailing whitespace from a string.
Example:
SELECT TRIM(column_name) FROM table_name;
2. UPPER() and LOWER():
Usage: Converts a string to uppercase or lowercase, respectively. This is useful for standardizing data.
Example:
SELECT UPPER(column_name) FROM table_name;
SELECT LOWER(column_name) FROM table_name;
3. COALESCE():
Usage: Returns the first non-null value in a list of arguments. It helps to handle null values effectively.
Example:
SELECT COALESCE(column1, column2, 'default_value') FROM table_name;
4. REPLACE():
Usage: Replaces occurrences of a specified string within another string, which can help in cleaning up data formats.
Example:
SELECT REPLACE(column_name, 'old_value', 'new_value') FROM table_name;
5. SUBSTRING():
Usage: Extracts a substring from a string based on specified starting position and length, useful for cleaning or formatting data.
Example:
SELECT SUBSTRING(column_name, start_position, length) FROM table_name;
6. CAST() and CONVERT():
Usage: Converts one data type to another. This is useful for ensuring data consistency across your database.
Example:
SELECT CAST(column_name AS VARCHAR(255)) FROM table_name;
SELECT CONVERT(VARCHAR(255), column_name) FROM table_name;
7. ISNULL():
Usage: Replaces NULL with a specified replacement value. This can help in making reports more readable.
Example:
SELECT ISNULL(column_name, 'default_value') FROM table_name;
Here you can find SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Hope it helps :)
1. TRIM():
Usage: Removes leading and trailing whitespace from a string.
Example:
SELECT TRIM(column_name) FROM table_name;
2. UPPER() and LOWER():
Usage: Converts a string to uppercase or lowercase, respectively. This is useful for standardizing data.
Example:
SELECT UPPER(column_name) FROM table_name;
SELECT LOWER(column_name) FROM table_name;
3. COALESCE():
Usage: Returns the first non-null value in a list of arguments. It helps to handle null values effectively.
Example:
SELECT COALESCE(column1, column2, 'default_value') FROM table_name;
4. REPLACE():
Usage: Replaces occurrences of a specified string within another string, which can help in cleaning up data formats.
Example:
SELECT REPLACE(column_name, 'old_value', 'new_value') FROM table_name;
5. SUBSTRING():
Usage: Extracts a substring from a string based on specified starting position and length, useful for cleaning or formatting data.
Example:
SELECT SUBSTRING(column_name, start_position, length) FROM table_name;
6. CAST() and CONVERT():
Usage: Converts one data type to another. This is useful for ensuring data consistency across your database.
Example:
SELECT CAST(column_name AS VARCHAR(255)) FROM table_name;
SELECT CONVERT(VARCHAR(255), column_name) FROM table_name;
7. ISNULL():
Usage: Replaces NULL with a specified replacement value. This can help in making reports more readable.
Example:
SELECT ISNULL(column_name, 'default_value') FROM table_name;
Here you can find SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Hope it helps :)
๐4โค1
SQL books wonโt teach you this.
Natural Keys vs. Autoincrement IDs vs. Public IDs. (or maybe all together)
๐ก๐ฎ๐๐๐ฟ๐ฎ๐น ๐๐ฒ๐๐
Natural keys carry intrinsic meaning because they are part of the domain.
They are directly related to the data, making them intuitive and easy to understand. Examples include email addresses or employee IDs.
The problem is that they are usually not good for performance, but they can also be a security risk if you expose them.
๐๐๐๐ผ๐ถ๐ป๐ฐ๐ฟ๐ฒ๐บ๐ฒ๐ป๐ ๐๐๐
Autoincrement IDs automatically generate unique integers to identify rows within a table.
They are often used as primary keys.
Simple integers are fast for the database to index and query. They provide optimal performance.
However, they are vulnerable to enumeration attacks since predicting the next or previous record is easy.
๐ฃ๐๐ฏ๐น๐ถ๐ฐ ๐๐๐ (๐จ๐จ๐๐๐)
UUIDs (Universally Unique Identifiers) are 128-bit identifiers used to uniquely identify information without relying on a centralized authority.
They are difficult to guess, making them suitable for public exposure in APIs.
The problem is they are larger and more complex than integers. This can impact performance, particularly in indexing and storage.
๐๐ถ๐ป๐ฑ๐ถ๐ป๐ด ๐๐ต๐ฒ ๐ฆ๐๐ฒ๐ฒ๐ ๐ฆ๐ฝ๐ผ๐: ๐ ๐ ๐ถ๐ ๐ฒ๐ฑ ๐๐ฝ๐ฝ๐ฟ๐ผ๐ฎ๐ฐ๐ต
Combining different types of keys can offer a balanced solution:
โข InternalID: Used for internal operations and relationships between tables.
โข PublicID: Used in API responses and endpoints to securely reference user records.
โข Email (Natural Key): Used to ensure unique identification of users within the business logic.
The mixed approach keeps your system fast, secure, and easy to understand.
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
Natural Keys vs. Autoincrement IDs vs. Public IDs. (or maybe all together)
๐ก๐ฎ๐๐๐ฟ๐ฎ๐น ๐๐ฒ๐๐
Natural keys carry intrinsic meaning because they are part of the domain.
They are directly related to the data, making them intuitive and easy to understand. Examples include email addresses or employee IDs.
The problem is that they are usually not good for performance, but they can also be a security risk if you expose them.
๐๐๐๐ผ๐ถ๐ป๐ฐ๐ฟ๐ฒ๐บ๐ฒ๐ป๐ ๐๐๐
Autoincrement IDs automatically generate unique integers to identify rows within a table.
They are often used as primary keys.
Simple integers are fast for the database to index and query. They provide optimal performance.
However, they are vulnerable to enumeration attacks since predicting the next or previous record is easy.
๐ฃ๐๐ฏ๐น๐ถ๐ฐ ๐๐๐ (๐จ๐จ๐๐๐)
UUIDs (Universally Unique Identifiers) are 128-bit identifiers used to uniquely identify information without relying on a centralized authority.
They are difficult to guess, making them suitable for public exposure in APIs.
The problem is they are larger and more complex than integers. This can impact performance, particularly in indexing and storage.
๐๐ถ๐ป๐ฑ๐ถ๐ป๐ด ๐๐ต๐ฒ ๐ฆ๐๐ฒ๐ฒ๐ ๐ฆ๐ฝ๐ผ๐: ๐ ๐ ๐ถ๐ ๐ฒ๐ฑ ๐๐ฝ๐ฝ๐ฟ๐ผ๐ฎ๐ฐ๐ต
Combining different types of keys can offer a balanced solution:
โข InternalID: Used for internal operations and relationships between tables.
โข PublicID: Used in API responses and endpoints to securely reference user records.
โข Email (Natural Key): Used to ensure unique identification of users within the business logic.
The mixed approach keeps your system fast, secure, and easy to understand.
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐4๐ค1
14 Days Roadmap to learn SQL
๐๐ฎ๐ ๐ญ: ๐๐ป๐๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐ผ๐ป ๐๐ผ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ๐ ๐ฎ๐ป๐ฑ ๐ฆ๐ค๐
Topics to Cover:
- What is SQL?
- Different types of databases (Relational vs. Non-Relational)
- SQL vs. NoSQL
- Overview of SQL syntax
Practice:
- Install a SQL database (e.g., MySQL, PostgreSQL, SQLite)
- Explore an online SQL editor like SQLFiddle or DB Fiddle
๐๐ฎ๐ ๐ฎ: ๐๐ฎ๐๐ถ๐ฐ ๐ฆ๐ค๐ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐
Topics to Cover:
- SELECT statement
- Filtering with WHERE clause
- DISTINCT keyword
Practice:
- Write simple SELECT queries to retrieve data from single table
- Filter records using WHERE clauses
๐๐ฎ๐ ๐ฏ: ๐ฆ๐ผ๐ฟ๐๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐๐ถ๐น๐๐ฒ๐ฟ๐ถ๐ป๐ด
Topics to Cover:
- ORDER BY clause
- Using LIMIT/OFFSET for pagination
- Comparison and logical operators
Practice:
- Sort data with ORDER BY
- Apply filtering with multiple conditions use AND/OR
๐๐ฎ๐ ๐ฐ: ๐ฆ๐ค๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐ ๐ฎ๐ป๐ฑ ๐๐ด๐ด๐ฟ๐ฒ๐ด๐ฎ๐๐ถ๐ผ๐ป๐
Topics to Cover:
- Aggregate functions (COUNT, SUM, AVG, MIN, MAX)
- GROUP BY and HAVING clauses
Practice:
- Perform aggregation on dataset
- Group data and filter groups using HAVING
๐๐ฎ๐ ๐ฑ: ๐ช๐ผ๐ฟ๐ธ๐ถ๐ป๐ด ๐๐ถ๐๐ต ๐ ๐๐น๐๐ถ๐ฝ๐น๐ฒ ๐ง๐ฎ๐ฏ๐น๐ฒ๐ - ๐๐ผ๐ถ๐ป๐
Topics to Cover:
- Introduction to Joins (INNER, LEFT, RIGHT, FULL)
- CROSS JOIN and self-joins
Practice:
- Write queries using different types of JOINs to combine data from multiple table
๐๐ฎ๐ ๐ฒ: ๐ฆ๐๐ฏ๐พ๐๐ฒ๐ฟ๐ถ๐ฒ๐ ๐ฎ๐ป๐ฑ ๐ก๐ฒ๐๐๐ฒ๐ฑ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐
Topics to Cover:
- Subqueries in SELECT, WHERE, and FROM clauses
- Correlated subqueries
Practice:
- Write subqueries to filter, aggregate, an select data
๐๐ฎ๐ ๐ณ: ๐๐ฎ๐๐ฎ ๐ ๐ผ๐ฑ๐ฒ๐น๐น๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ ๐๐ฒ๐๐ถ๐ด๐ป
Topics to Cover:
- Understanding ERD (Entity Relationship Diagram)
- Normalization (1NF, 2NF, 3NF)
- Primary and Foreign Key
Practice:
- Design a simple database schema and implement it in your database
๐๐ฎ๐ ๐ด: ๐ ๐ผ๐ฑ๐ถ๐ณ๐๐ถ๐ป๐ด ๐๐ฎ๐๐ฎ - ๐๐ก๐ฆ๐๐ฅ๐ง, ๐จ๐ฃ๐๐๐ง๐, ๐๐๐๐๐ง๐
Topics to Cover:
- INSERT INTO statement
- UPDATE and DELETE statement
- Transactions and rollback
Practice:
- Insert, update, and delete records in a table
- Practice transactions with COMMIT and ROLLBACK
๐๐ฎ๐ ๐ต: ๐๐ฑ๐๐ฎ๐ป๐ฐ๐ฒ๐ฑ ๐ฆ๐ค๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐
Topics to Cover:
- String functions (CONCAT, SUBSTR, etc.)
- Date functions (NOW, DATEADD, DATEDIFF)
- CASE statement
Practice:
- Use string and date function in queries
- Write conditional logic using CASE
๐๐ฎ๐ ๐ญ๐ฌ: ๐ฉ๐ถ๐ฒ๐๐ ๐ฎ๐ป๐ฑ ๐๐ป๐ฑ๐ฒ๐ ๐ฒ๐
Topics to Cover:
- Creating and using Views
- Indexes: What they are and how they work
- Pros and cons of using indexes
Practice:
- Create and query views
- Explore how indexes affect query performance
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐๐ฎ๐ ๐ญ: ๐๐ป๐๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐ผ๐ป ๐๐ผ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ๐ ๐ฎ๐ป๐ฑ ๐ฆ๐ค๐
Topics to Cover:
- What is SQL?
- Different types of databases (Relational vs. Non-Relational)
- SQL vs. NoSQL
- Overview of SQL syntax
Practice:
- Install a SQL database (e.g., MySQL, PostgreSQL, SQLite)
- Explore an online SQL editor like SQLFiddle or DB Fiddle
๐๐ฎ๐ ๐ฎ: ๐๐ฎ๐๐ถ๐ฐ ๐ฆ๐ค๐ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐
Topics to Cover:
- SELECT statement
- Filtering with WHERE clause
- DISTINCT keyword
Practice:
- Write simple SELECT queries to retrieve data from single table
- Filter records using WHERE clauses
๐๐ฎ๐ ๐ฏ: ๐ฆ๐ผ๐ฟ๐๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐๐ถ๐น๐๐ฒ๐ฟ๐ถ๐ป๐ด
Topics to Cover:
- ORDER BY clause
- Using LIMIT/OFFSET for pagination
- Comparison and logical operators
Practice:
- Sort data with ORDER BY
- Apply filtering with multiple conditions use AND/OR
๐๐ฎ๐ ๐ฐ: ๐ฆ๐ค๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐ ๐ฎ๐ป๐ฑ ๐๐ด๐ด๐ฟ๐ฒ๐ด๐ฎ๐๐ถ๐ผ๐ป๐
Topics to Cover:
- Aggregate functions (COUNT, SUM, AVG, MIN, MAX)
- GROUP BY and HAVING clauses
Practice:
- Perform aggregation on dataset
- Group data and filter groups using HAVING
๐๐ฎ๐ ๐ฑ: ๐ช๐ผ๐ฟ๐ธ๐ถ๐ป๐ด ๐๐ถ๐๐ต ๐ ๐๐น๐๐ถ๐ฝ๐น๐ฒ ๐ง๐ฎ๐ฏ๐น๐ฒ๐ - ๐๐ผ๐ถ๐ป๐
Topics to Cover:
- Introduction to Joins (INNER, LEFT, RIGHT, FULL)
- CROSS JOIN and self-joins
Practice:
- Write queries using different types of JOINs to combine data from multiple table
๐๐ฎ๐ ๐ฒ: ๐ฆ๐๐ฏ๐พ๐๐ฒ๐ฟ๐ถ๐ฒ๐ ๐ฎ๐ป๐ฑ ๐ก๐ฒ๐๐๐ฒ๐ฑ ๐ค๐๐ฒ๐ฟ๐ถ๐ฒ๐
Topics to Cover:
- Subqueries in SELECT, WHERE, and FROM clauses
- Correlated subqueries
Practice:
- Write subqueries to filter, aggregate, an select data
๐๐ฎ๐ ๐ณ: ๐๐ฎ๐๐ฎ ๐ ๐ผ๐ฑ๐ฒ๐น๐น๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ ๐๐ฒ๐๐ถ๐ด๐ป
Topics to Cover:
- Understanding ERD (Entity Relationship Diagram)
- Normalization (1NF, 2NF, 3NF)
- Primary and Foreign Key
Practice:
- Design a simple database schema and implement it in your database
๐๐ฎ๐ ๐ด: ๐ ๐ผ๐ฑ๐ถ๐ณ๐๐ถ๐ป๐ด ๐๐ฎ๐๐ฎ - ๐๐ก๐ฆ๐๐ฅ๐ง, ๐จ๐ฃ๐๐๐ง๐, ๐๐๐๐๐ง๐
Topics to Cover:
- INSERT INTO statement
- UPDATE and DELETE statement
- Transactions and rollback
Practice:
- Insert, update, and delete records in a table
- Practice transactions with COMMIT and ROLLBACK
๐๐ฎ๐ ๐ต: ๐๐ฑ๐๐ฎ๐ป๐ฐ๐ฒ๐ฑ ๐ฆ๐ค๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐
Topics to Cover:
- String functions (CONCAT, SUBSTR, etc.)
- Date functions (NOW, DATEADD, DATEDIFF)
- CASE statement
Practice:
- Use string and date function in queries
- Write conditional logic using CASE
๐๐ฎ๐ ๐ญ๐ฌ: ๐ฉ๐ถ๐ฒ๐๐ ๐ฎ๐ป๐ฑ ๐๐ป๐ฑ๐ฒ๐ ๐ฒ๐
Topics to Cover:
- Creating and using Views
- Indexes: What they are and how they work
- Pros and cons of using indexes
Practice:
- Create and query views
- Explore how indexes affect query performance
Here you can find essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐12
๐๐ป๐๐ฒ๐ฟ๐๐ถ๐ฒ๐๐ฒ๐ฟ: You have 2 minutes to solve this SQL query.
Retrieve the department name and the highest salary in each department from the
๐ ๐ฒ: Challenge accepted!
SELECT department, MAX(salary) AS highest_salary
FROM employees
GROUP BY department
HAVING MAX(salary) > 70000;
I used
๐ง๐ถ๐ฝ ๐ณ๐ผ๐ฟ ๐ฆ๐ค๐ ๐๐ผ๐ฏ ๐ฆ๐ฒ๐ฒ๐ธ๐ฒ๐ฟ๐:
It's not about writing complex queries; it's about writing clean, efficient, and scalable code. Focus on mastering subqueries, joins, and aggregation functions to stand out!
I have curated essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
Retrieve the department name and the highest salary in each department from the
employees table, but only for departments where the highest salary is greater than $70,000.๐ ๐ฒ: Challenge accepted!
SELECT department, MAX(salary) AS highest_salary
FROM employees
GROUP BY department
HAVING MAX(salary) > 70000;
I used
GROUP BY to group employees by department, MAX() to get the highest salary, and HAVING to filter the result based on the condition that the highest salary exceeds $70,000. This solution effectively shows my understanding of aggregation functions and how to apply conditions on the result of those aggregations.๐ง๐ถ๐ฝ ๐ณ๐ผ๐ฟ ๐ฆ๐ค๐ ๐๐ผ๐ฏ ๐ฆ๐ฒ๐ฒ๐ธ๐ฒ๐ฟ๐:
It's not about writing complex queries; it's about writing clean, efficient, and scalable code. Focus on mastering subqueries, joins, and aggregation functions to stand out!
I have curated essential SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐5โค1
I've compiled a list of important SQL interview questions to help you prepare for your next data analytics interview. These questions cover everything from basic to advanced topics. Letโs dive in!๐
1. What is the purpose of the GROUP BY clause in SQL? Provide an example.
2. Explain the difference between an INNER JOIN and a LEFT JOIN with examples.
3. Discuss the role of the WHERE clause in SQL queries and provide examples of its usage.
4. Explain the concept of database transactions and the ACID properties.
5. Describe the benefits of using subqueries in SQL and provide a scenario where they would be useful.
6. Discuss the differences between the CHAR and VARCHAR data types in SQL.
7. Explain the purpose of the ORDER BY clause in SQL queries and provide examples.
8. Describe the importance of data integrity constraints such as NOT NULL, UNIQUE, and CHECK constraints in SQL databases.
9. Discuss the advantages and disadvantages of using stored procedures
Explain the difference between an aggregate function and a scalar function in SQL, with examples.
10. Discuss the role of the COMMIT and ROLLBACK statements in SQL transactions.
11. Explain the purpose of the LIKE operator in SQL and provide examples of its usage.
12. Describe the concept of normalization forms (1NF, 2NF, 3NF) and why they are important in database design.
13. Discuss the differences between a clustered and non-clustered index in SQL.
14. Explain the concept of data warehousing and how it differs from traditional relational databases.
15. Describe the benefits of using database triggers and provide examples of their usage.
16. Discuss the concept of database concurrency control and how it is achieved in SQL databases.
17. Explain the role of the SELECT INTO statement in SQL and provide examples of its usage.
18. Describe the differences between a database view and a materialized view in SQL.
19. Discuss the advantages of using parameterized queries in SQL applications.
20. Write a query to retrieve all employees who have a salary greater than $100,000.
21. Create a query to display the total number of orders placed in the last month.
22. Write a query to find the average order value for each customer.
23. Create a query to count the number of distinct products sold in the past week.
24. Write a query to find the top 10 customers with the highest total order amount.
Here you can find SQL Interview Resources๐
t.iss.one/mysqldata
Hope it helps :)
1. What is the purpose of the GROUP BY clause in SQL? Provide an example.
2. Explain the difference between an INNER JOIN and a LEFT JOIN with examples.
3. Discuss the role of the WHERE clause in SQL queries and provide examples of its usage.
4. Explain the concept of database transactions and the ACID properties.
5. Describe the benefits of using subqueries in SQL and provide a scenario where they would be useful.
6. Discuss the differences between the CHAR and VARCHAR data types in SQL.
7. Explain the purpose of the ORDER BY clause in SQL queries and provide examples.
8. Describe the importance of data integrity constraints such as NOT NULL, UNIQUE, and CHECK constraints in SQL databases.
9. Discuss the advantages and disadvantages of using stored procedures
Explain the difference between an aggregate function and a scalar function in SQL, with examples.
10. Discuss the role of the COMMIT and ROLLBACK statements in SQL transactions.
11. Explain the purpose of the LIKE operator in SQL and provide examples of its usage.
12. Describe the concept of normalization forms (1NF, 2NF, 3NF) and why they are important in database design.
13. Discuss the differences between a clustered and non-clustered index in SQL.
14. Explain the concept of data warehousing and how it differs from traditional relational databases.
15. Describe the benefits of using database triggers and provide examples of their usage.
16. Discuss the concept of database concurrency control and how it is achieved in SQL databases.
17. Explain the role of the SELECT INTO statement in SQL and provide examples of its usage.
18. Describe the differences between a database view and a materialized view in SQL.
19. Discuss the advantages of using parameterized queries in SQL applications.
20. Write a query to retrieve all employees who have a salary greater than $100,000.
21. Create a query to display the total number of orders placed in the last month.
22. Write a query to find the average order value for each customer.
23. Create a query to count the number of distinct products sold in the past week.
24. Write a query to find the top 10 customers with the highest total order amount.
Here you can find SQL Interview Resources๐
t.iss.one/mysqldata
Hope it helps :)
Telegram
SQL For Data Analytics
This channel covers everything you need to learn SQL for data science, data analyst, data engineer and business analyst roles.
๐4โค3๐1
SQL Cheatsheet ๐
This SQL cheatsheet is designed to be your quick reference guide for SQL programming. Whether youโre a beginner learning how to query databases or an experienced developer looking for a handy resource, this cheatsheet covers essential SQL topics.
1. Database Basics
-
-
2. Tables
- Create Table:
- Drop Table:
- Alter Table:
3. Insert Data
-
4. Select Queries
- Basic Select:
- Select Specific Columns:
- Select with Condition:
5. Update Data
-
6. Delete Data
-
7. Joins
- Inner Join:
- Left Join:
- Right Join:
8. Aggregations
- Count:
- Sum:
- Group By:
9. Sorting & Limiting
- Order By:
- Limit Results:
10. Indexes
- Create Index:
- Drop Index:
11. Subqueries
-
12. Views
- Create View:
- Drop View:
Here you can find SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
This SQL cheatsheet is designed to be your quick reference guide for SQL programming. Whether youโre a beginner learning how to query databases or an experienced developer looking for a handy resource, this cheatsheet covers essential SQL topics.
1. Database Basics
-
CREATE DATABASE db_name;-
USE db_name;2. Tables
- Create Table:
CREATE TABLE table_name (col1 datatype, col2 datatype);- Drop Table:
DROP TABLE table_name;- Alter Table:
ALTER TABLE table_name ADD column_name datatype;3. Insert Data
-
INSERT INTO table_name (col1, col2) VALUES (val1, val2);4. Select Queries
- Basic Select:
SELECT * FROM table_name;- Select Specific Columns:
SELECT col1, col2 FROM table_name;- Select with Condition:
SELECT * FROM table_name WHERE condition;5. Update Data
-
UPDATE table_name SET col1 = value1 WHERE condition;6. Delete Data
-
DELETE FROM table_name WHERE condition;7. Joins
- Inner Join:
SELECT * FROM table1 INNER JOIN table2 ON table1.col = table2.col;- Left Join:
SELECT * FROM table1 LEFT JOIN table2 ON table1.col = table2.col;- Right Join:
SELECT * FROM table1 RIGHT JOIN table2 ON table1.col = table2.col;8. Aggregations
- Count:
SELECT COUNT(*) FROM table_name;- Sum:
SELECT SUM(col) FROM table_name;- Group By:
SELECT col, COUNT(*) FROM table_name GROUP BY col;9. Sorting & Limiting
- Order By:
SELECT * FROM table_name ORDER BY col ASC|DESC;- Limit Results:
SELECT * FROM table_name LIMIT n;10. Indexes
- Create Index:
CREATE INDEX idx_name ON table_name (col);- Drop Index:
DROP INDEX idx_name;11. Subqueries
-
SELECT * FROM table_name WHERE col IN (SELECT col FROM other_table);12. Views
- Create View:
CREATE VIEW view_name AS SELECT * FROM table_name;- Drop View:
DROP VIEW view_name;Here you can find SQL Interview Resources๐
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Share with credits: https://t.iss.one/sqlspecialist
Hope it helps :)
โค8๐3
Best practices for writing SQL queries:
1- Filter Early, Aggregate Late: Apply filtering conditions in the WHERE clause early in the query, and perform aggregations in the HAVING or SELECT clauses as needed.
2- Use table aliases with columns when you are joining multiple tables.
3- Never use select *, always mention list of columns in select clause before deploying the code.
4- Add useful comments wherever you write complex logic. Avoid too many comments.
5- Use joins instead of correlated subqueries when possible for better performance.
6- Create CTEs instead of multiple sub queries, it will make your query easy to read.
7- Join tables using JOIN keywords instead of writing join condition in where clause for better readability.
8- Never use order by in sub queries, It will unnecessary increase runtime. In fact some databases don't even allow you to do that.
9- If you know there are no duplicates in 2 tables, use UNION ALL instead of UNION for better performance.
1- Filter Early, Aggregate Late: Apply filtering conditions in the WHERE clause early in the query, and perform aggregations in the HAVING or SELECT clauses as needed.
2- Use table aliases with columns when you are joining multiple tables.
3- Never use select *, always mention list of columns in select clause before deploying the code.
4- Add useful comments wherever you write complex logic. Avoid too many comments.
5- Use joins instead of correlated subqueries when possible for better performance.
6- Create CTEs instead of multiple sub queries, it will make your query easy to read.
7- Join tables using JOIN keywords instead of writing join condition in where clause for better readability.
8- Never use order by in sub queries, It will unnecessary increase runtime. In fact some databases don't even allow you to do that.
9- If you know there are no duplicates in 2 tables, use UNION ALL instead of UNION for better performance.
โค4๐3๐ค1
Most Asked SQL Interview Questions at MAANG Companies๐ฅ๐ฅ
Preparing for an SQL Interview at MAANG Companies? Here are some crucial SQL Questions you should be ready to tackle:
1. How do you retrieve all columns from a table?
SELECT * FROM table_name;
2. What SQL statement is used to filter records?
SELECT * FROM table_name
WHERE condition;
The WHERE clause is used to filter records based on a specified condition.
3. How can you join multiple tables? Describe different types of JOINs.
SELECT columns
FROM table1
JOIN table2 ON table1.column = table2.column
JOIN table3 ON table2.column = table3.column;
Types of JOINs:
1. INNER JOIN: Returns records with matching values in both tables
SELECT * FROM table1
INNER JOIN table2 ON table1.column = table2.column;
2. LEFT JOIN: Returns all records from the left table & matched records from the right table. Unmatched records will have NULL values.
SELECT * FROM table1
LEFT JOIN table2 ON table1.column = table2.column;
3. RIGHT JOIN: Returns all records from the right table & matched records from the left table. Unmatched records will have NULL values.
SELECT * FROM table1
RIGHT JOIN table2 ON table1.column = table2.column;
4. FULL JOIN: Returns records when there is a match in either left or right table. Unmatched records will have NULL values.
SELECT * FROM table1
FULL JOIN table2 ON table1.column = table2.column;
4. What is the difference between WHERE & HAVING clauses?
WHERE: Filters records before any groupings are made.
SELECT * FROM table_name
WHERE condition;
HAVING: Filters records after groupings are made.
SELECT column, COUNT(*)
FROM table_name
GROUP BY column
HAVING COUNT(*) > value;
5. How do you calculate average, sum, minimum & maximum values in a column?
Average: SELECT AVG(column_name) FROM table_name;
Sum: SELECT SUM(column_name) FROM table_name;
Minimum: SELECT MIN(column_name) FROM table_name;
Maximum: SELECT MAX(column_name) FROM table_name;
Like this post if you need more ๐โค๏ธ
Hope it helps :)
Preparing for an SQL Interview at MAANG Companies? Here are some crucial SQL Questions you should be ready to tackle:
1. How do you retrieve all columns from a table?
SELECT * FROM table_name;
2. What SQL statement is used to filter records?
SELECT * FROM table_name
WHERE condition;
The WHERE clause is used to filter records based on a specified condition.
3. How can you join multiple tables? Describe different types of JOINs.
SELECT columns
FROM table1
JOIN table2 ON table1.column = table2.column
JOIN table3 ON table2.column = table3.column;
Types of JOINs:
1. INNER JOIN: Returns records with matching values in both tables
SELECT * FROM table1
INNER JOIN table2 ON table1.column = table2.column;
2. LEFT JOIN: Returns all records from the left table & matched records from the right table. Unmatched records will have NULL values.
SELECT * FROM table1
LEFT JOIN table2 ON table1.column = table2.column;
3. RIGHT JOIN: Returns all records from the right table & matched records from the left table. Unmatched records will have NULL values.
SELECT * FROM table1
RIGHT JOIN table2 ON table1.column = table2.column;
4. FULL JOIN: Returns records when there is a match in either left or right table. Unmatched records will have NULL values.
SELECT * FROM table1
FULL JOIN table2 ON table1.column = table2.column;
4. What is the difference between WHERE & HAVING clauses?
WHERE: Filters records before any groupings are made.
SELECT * FROM table_name
WHERE condition;
HAVING: Filters records after groupings are made.
SELECT column, COUNT(*)
FROM table_name
GROUP BY column
HAVING COUNT(*) > value;
5. How do you calculate average, sum, minimum & maximum values in a column?
Average: SELECT AVG(column_name) FROM table_name;
Sum: SELECT SUM(column_name) FROM table_name;
Minimum: SELECT MIN(column_name) FROM table_name;
Maximum: SELECT MAX(column_name) FROM table_name;
Like this post if you need more ๐โค๏ธ
Hope it helps :)
๐12โค2