SQL Programming Resources
75.8K subscribers
509 photos
13 files
451 links
Find top SQL resources from global universities, cool projects, and learning materials for data analytics.

Admin: @coderfun

Useful links: heylink.me/DataAnalytics

Promotions: @love_data
Download Telegram
15 essential sql interview questions

1️⃣ Explain Order of Execution of SQL query
2️⃣ Provide a use case for each of the functions Rank, Dense_Rank & Row_Number ( 💡 majority struggle )
3️⃣ Write a query to find the cumulative sum/Running Total
4️⃣ Find the Most selling product by sales/ highest Salary of employees
5️⃣ Write a query to find the 2nd/nth highest Salary of employees
6️⃣ Difference between union vs union all
7️⃣ Identify if there any duplicates in a table
8️⃣ Scenario based Joins question, understanding of Inner, Left and Outer Joins via simple yet tricky question
9️⃣ LAG, write a query to find all those records where the transaction value is greater then previous transaction value
1️⃣ 0️⃣ Rank vs Dense Rank, query to find the 2nd highest Salary of employee
( Ideal soln should handle ties)
1️⃣ 1️⃣ Write a query to find the Running Difference (Ideal sol'n using windows function)
1️⃣ 2️⃣ Write a query to display year on year/month on month growth
1️⃣ 3️⃣ Write a query to find rolling average of daily sign-ups
1️⃣ 4️⃣ Write a query to find the running difference using self join (helps in understanding the logical approach, ideally this question is solved via windows function)
1️⃣ 5️⃣ Write a query to find the cumulative sum using self join
(helps in understanding the logical approach, ideally this question is solved via windows function

Here you can find essential SQL Interview Resources👇
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v

Like this post if you need more 👍❤️

Hope it helps :)
👍4👏2
Must Know Differences for SQL :



👉 INNER JOIN vs OUTER JOIN:
INNER JOIN: Returns only matching rows from both tables.
OUTER JOIN: Returns matching rows plus non-matching rows from one or both tables (LEFT, RIGHT, or FULL).

👉 VARCHAR vs NVARCHAR:
VARCHAR: Stores non-Unicode characters, taking 1 byte per character.
NVARCHAR: Stores Unicode characters, taking 2 bytes per character.

👉 PRIMARY KEY vs UNIQUE KEY:
PRIMARY KEY: Ensures unique values and does not allow NULLs.
UNIQUE KEY: Ensures unique values but allows a single NULL.

👉 CLUSTERED INDEX vs NON-CLUSTERED INDEX:
CLUSTERED INDEX: Sorts and stores data rows in the table based on the indexed column.
NON-CLUSTERED INDEX: Creates a separate structure from the data rows, with pointers to the original data.

👉 TEMPORARY TABLE vs TABLE VARIABLE:
TEMPORARY TABLE: Created in the tempdb database, persists for the session or until dropped.
TABLE VARIABLE: Stored in memory, scoped to the batch or stored procedure, and typically faster for small datasets.

👉 VIEW vs MATERIALIZED VIEW:
VIEW: A virtual table that does not store data, dynamically retrieves data from the base tables.
MATERIALIZED VIEW: Stores the result of the query physically, providing faster access to large datasets.

👉 STORED PROCEDURE vs FUNCTION:
STORED PROCEDURE: Executes a set of SQL statements and can return multiple values, including result sets.
FUNCTION: Returns a single value or table and can be used in SQL expressions.

👉 SIMPLE RECOVERY MODEL vs FULL RECOVERY MODEL:
SIMPLE RECOVERY MODEL: Does not log transactions in detail, preventing point-in-time restores.
FULL RECOVERY MODEL: Logs all transactions, allowing for point-in-time restores.

👉 RAISERROR vs THROW:
RAISERROR: Used to generate a custom error message, providing more control over the error handling.
THROW: Simplified error handling, introduced in SQL Server 2012, and rethrows the error.

👉 DELETE vs TRUNCATE:
DELETE: Removes rows based on a condition and logs each row deletion.
TRUNCATE: Removes all rows from a table quickly without logging individual row deletions.

Here you can find essential SQL Interview Resources👇
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v

Like this post if you need more 👍❤️

Hope it helps :)
👍71
SQL topics that are important for a data analyst role:

Basic SQL Queries
SELECT Statements: Retrieve data from databases.
WHERE Clause: Filter records based on specified conditions.
ORDER BY: Sort results.
LIMIT: Limit the number of returned rows.

  Data Aggregation
GROUP BY: Group rows that have the same values in specified columns.
HAVING Clause: Filter groups based on a specified condition.
Aggregate Functions: COUNT(), SUM(), AVG(), MIN(), MAX().

Joins
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
SELF JOIN
CROSS JOIN

Advanced SQL Concepts
Subqueries (Nested Queries): Query within another query.
Common Table Expressions (CTEs): Temporary result set that can be referenced within another SELECT, INSERT, UPDATE, or DELETE statement.

Window Functions: Perform calculations across a set of table rows related to the current row (e.g., ROW_NUMBER(), RANK(), DENSE_RANK(), LEAD(), LAG()).

UNION and UNION ALL: Combine the results of two or more SELECT statements.

Data Manipulation
INSERT INTO: Add new rows to a table.
UPDATE: Modify existing records.
DELETE: Remove existing records.

Data Definition
CREATE TABLE: Define a new table.
ALTER TABLE: Modify an existing table.
DROP TABLE: Delete a table.
Primary and Foreign Keys: Enforce data integrity and relationships between tables.
Indexes: Improve the speed of data retrieval.

Performance Tuning
Query Optimization: Techniques to improve query performance (e.g., indexing, avoiding unnecessary columns in SELECT, avoiding SELECT *).
Execution Plans: Analyze how SQL statements are executed to optimize performance.

SQL Functions
String Functions: CONCAT(), SUBSTRING(), REPLACE(), LENGTH().
Date and Time Functions: NOW(), CURDATE(), DATEADD(), DATEDIFF().
Numeric Functions: ROUND(), CEIL(), FLOOR().

Error Handling
TRY...CATCH: Handle errors in SQL code (available in some SQL dialects).
Transaction Control: BEGIN TRANSACTION, COMMIT, and ROLLBACK to ensure data integrity.

Data Analysis Specific
Pivoting and Unpivoting: Convert rows to columns and vice versa.
Creating Reports: Using SQL to generate detailed data reports.
Data Cleaning and Transformation: Techniques to prepare data for analysis.

Database Management
User Permissions and Roles: Manage access control.
Backup and Restore: Ensure data safety and recovery.

Practical Use Cases
Real-world scenarios: Understanding and solving business problems using SQL.
Case Studies: Applying SQL knowledge to actual data sets and business requirements.

Here you can find SQL Interview Resources👇
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v

Hope it helps :)
👍52
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
👍81
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 :)
👍2
Top 5 SQL Functions

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 :)
👍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 :)
👍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;
👍101
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 :)
👍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 :)
👍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 )
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 :)
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 :)
👍72
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 :)
👍41
SQL Cheatsheet
10
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 :)
👍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 :)
👍12
𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝗲𝗿: You have 2 minutes to solve this SQL query.
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 :)
👍51
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 :)
👍43😍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
   - 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