What does the following SQL query return?
SELECT COUNT(email) FROM customers;
SELECT COUNT(email) FROM customers;
Anonymous Quiz
23%
Total number of customers, including NULL emails
32%
Total number of customers whose email is NOT NULL
17%
Total number of different email domains
28%
Total number of customers with Gmail accounts
👍13❤1
7 High-Impact Portfolio Project Ideas for Aspiring Data Analysts
✅ Sales Dashboard – Use Power BI or Tableau to visualize KPIs like revenue, profit, and region-wise performance
✅ Customer Churn Analysis – Predict which customers are likely to leave using Python (Logistic Regression, EDA)
✅ Netflix Dataset Exploration – Analyze trends in content types, genres, and release years with Pandas & Matplotlib
✅ HR Analytics Dashboard – Visualize attrition, department strength, and performance reviews
✅ Survey Data Analysis – Clean, visualize, and derive insights from user feedback or product surveys
✅ E-commerce Product Analysis – Analyze top-selling products, revenue by category, and return rates
✅ Airbnb Price Predictor – Use machine learning to predict listing prices based on location, amenities, and ratings
These projects showcase real-world skills and storytelling with data.
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
✅ Sales Dashboard – Use Power BI or Tableau to visualize KPIs like revenue, profit, and region-wise performance
✅ Customer Churn Analysis – Predict which customers are likely to leave using Python (Logistic Regression, EDA)
✅ Netflix Dataset Exploration – Analyze trends in content types, genres, and release years with Pandas & Matplotlib
✅ HR Analytics Dashboard – Visualize attrition, department strength, and performance reviews
✅ Survey Data Analysis – Clean, visualize, and derive insights from user feedback or product surveys
✅ E-commerce Product Analysis – Analyze top-selling products, revenue by category, and return rates
✅ Airbnb Price Predictor – Use machine learning to predict listing prices based on location, amenities, and ratings
These projects showcase real-world skills and storytelling with data.
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤8👍1
Data Analytics
📊 Aggregate Functions (COUNT, SUM, AVG, MIN, MAX) Aggregate functions are used to perform calculations on multiple rows of a table and return a single value. They're mostly used with GROUP BY, but also work standalone. 1. COUNT() Returns the number of rows.…
👥 GROUP BY & HAVING Clauses
1. GROUP BY
GROUP BY is used to group rows that have the same values in specified columns and apply aggregate functions to each group.
Syntax:
SELECT column, AGG_FUNC(column2) FROM table_name GROUP BY column;
Example:
SELECT department, COUNT(*) AS total_employees
FROM employees
GROUP BY department;
This shows how many employees are in each department.
You can group by multiple columns too:
SELECT department, job_noscript, AVG(salary) AS avg_salary
FROM employees
GROUP BY department, job_noscript;
2. HAVING
HAVING is like WHERE, but it’s used to filter grouped data. You can't use WHERE with aggregate functions — that's where HAVING comes in.
Example:
SELECT department, COUNT(*) AS total_employees
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
This gives you only those departments that have more than 5 employees.
Bonus: Combine GROUP BY + ORDER BY + HAVING:
SELECT category, SUM(sales) AS total_sales
FROM products
GROUP BY category
HAVING SUM(sales) > 10000
ORDER BY total_sales DESC;
This gives you the top-selling categories with sales over 10,000.
React with ❤️ if you’re ready for the next banger: 🔗 SQL JOINS (INNER, LEFT, RIGHT, FULL, SELF).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
1. GROUP BY
GROUP BY is used to group rows that have the same values in specified columns and apply aggregate functions to each group.
Syntax:
SELECT column, AGG_FUNC(column2) FROM table_name GROUP BY column;
Example:
SELECT department, COUNT(*) AS total_employees
FROM employees
GROUP BY department;
This shows how many employees are in each department.
You can group by multiple columns too:
SELECT department, job_noscript, AVG(salary) AS avg_salary
FROM employees
GROUP BY department, job_noscript;
2. HAVING
HAVING is like WHERE, but it’s used to filter grouped data. You can't use WHERE with aggregate functions — that's where HAVING comes in.
Example:
SELECT department, COUNT(*) AS total_employees
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
This gives you only those departments that have more than 5 employees.
Bonus: Combine GROUP BY + ORDER BY + HAVING:
SELECT category, SUM(sales) AS total_sales
FROM products
GROUP BY category
HAVING SUM(sales) > 10000
ORDER BY total_sales DESC;
This gives you the top-selling categories with sales over 10,000.
React with ❤️ if you’re ready for the next banger: 🔗 SQL JOINS (INNER, LEFT, RIGHT, FULL, SELF).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤11👍5🎉4
What will the following SQL query return?
SELECT department, COUNT(*) AS total_employees FROM employees GROUP BY department HAVING COUNT(*) > 10;
SELECT department, COUNT(*) AS total_employees FROM employees GROUP BY department HAVING COUNT(*) > 10;
Anonymous Quiz
40%
All employees in departments with more than 10 total employees
53%
Only the departments that have more than 10 employees
5%
Employees whose department has exactly 10 members
2%
All departments regardless of employee count
👍16❤2
Data Analytics
👥 GROUP BY & HAVING Clauses 1. GROUP BY GROUP BY is used to group rows that have the same values in specified columns and apply aggregate functions to each group. Syntax: SELECT column, AGG_FUNC(column2) FROM table_name GROUP BY column; Example: SELECT…
🔗 SQL JOINS (INNER, LEFT, RIGHT, FULL, SELF)
JOINS help you combine data from two or more tables based on a related column (usually a primary key and a foreign key).
1. INNER JOIN
Returns only matching rows between two tables.
SELECT customers.name, orders.order_id
FROM customers
INNER JOIN orders ON customers.id = orders.customer_id;
This returns only those customers who have placed at least one order.
2. LEFT JOIN (or LEFT OUTER JOIN)
Returns all rows from the left table, and matched rows from the right table. If no match, you'll see NULLs.
SELECT customers.name, orders.order_id
FROM customers
LEFT JOIN orders ON customers.id = orders.customer_id;
This shows all customers, including those who haven’t placed any orders.
3. RIGHT JOIN (or RIGHT OUTER JOIN)
Returns all rows from the right table, and matching rows from the left.
SELECT customers.name, orders.order_id
FROM customers
RIGHT JOIN orders ON customers.id = orders.customer_id;
You’ll see all orders — even if there’s no corresponding customer info.
4. FULL JOIN (or FULL OUTER JOIN)
Returns all rows from both tables. If there's no match, it returns NULLs.
Note: MySQL doesn't support FULL JOIN directly; use UNION of LEFT and RIGHT joins instead.
5. SELF JOIN
You join a table with itself. Great for hierarchical relationships.
SELECT e.name AS employee, m.name AS manager
FROM employees e
JOIN employees m ON e.manager_id = m.id;
This shows each employee along with their manager's name.
Pro Tip: Be careful with NULLs and always define clear join conditions to avoid cartesian products.
React with ❤️ if you're ready for the next one: 👇
📦 Subqueries & Nested Queries.
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
JOINS help you combine data from two or more tables based on a related column (usually a primary key and a foreign key).
1. INNER JOIN
Returns only matching rows between two tables.
SELECT customers.name, orders.order_id
FROM customers
INNER JOIN orders ON customers.id = orders.customer_id;
This returns only those customers who have placed at least one order.
2. LEFT JOIN (or LEFT OUTER JOIN)
Returns all rows from the left table, and matched rows from the right table. If no match, you'll see NULLs.
SELECT customers.name, orders.order_id
FROM customers
LEFT JOIN orders ON customers.id = orders.customer_id;
This shows all customers, including those who haven’t placed any orders.
3. RIGHT JOIN (or RIGHT OUTER JOIN)
Returns all rows from the right table, and matching rows from the left.
SELECT customers.name, orders.order_id
FROM customers
RIGHT JOIN orders ON customers.id = orders.customer_id;
You’ll see all orders — even if there’s no corresponding customer info.
4. FULL JOIN (or FULL OUTER JOIN)
Returns all rows from both tables. If there's no match, it returns NULLs.
Note: MySQL doesn't support FULL JOIN directly; use UNION of LEFT and RIGHT joins instead.
5. SELF JOIN
You join a table with itself. Great for hierarchical relationships.
SELECT e.name AS employee, m.name AS manager
FROM employees e
JOIN employees m ON e.manager_id = m.id;
This shows each employee along with their manager's name.
Pro Tip: Be careful with NULLs and always define clear join conditions to avoid cartesian products.
React with ❤️ if you're ready for the next one: 👇
📦 Subqueries & Nested Queries.
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤6👍5
What does a LEFT JOIN return?
Anonymous Quiz
5%
Only matching rows
6%
All rows from the right table
87%
All rows from the left table + matching rows from the right
2%
All rows from both tables
👏10
Data Analytics
🔗 SQL JOINS (INNER, LEFT, RIGHT, FULL, SELF) JOINS help you combine data from two or more tables based on a related column (usually a primary key and a foreign key). 1. INNER JOIN Returns only matching rows between two tables. SELECT customers.name, orders.order_id…
📦 Subqueries & Nested Queries
A subquery is a query inside another query. You can use it in SELECT, FROM, or WHERE clauses to solve complex problems step-by-step.
1. Subquery in WHERE Clause
Use this when you need to filter results based on another query.
SELECT name
FROM employees
WHERE department_id = (
SELECT id FROM departments WHERE name = 'Sales'
);
This finds all employees who work in the Sales department.
2. Subquery in SELECT Clause
This lets you fetch calculated or related values for each row.
SELECT name,
(SELECT AVG(salary) FROM employees) AS avg_salary
FROM employees;
Shows each employee’s name along with the company’s average salary.
3. Subquery in FROM Clause (Inline View)
Used when you want to treat the subquery like a temporary table.
SELECT department, total
FROM (
SELECT department, SUM(salary) AS total
FROM employees
GROUP BY department
) AS dept_summary;
This groups salaries by department in a subquery, then fetches from it.
Important:
- Always alias your subqueries (especially in the FROM clause).
- Avoid correlated subqueries if possible; they’re slower.
React with ❤️ if you want me to cover the next topic: 🏷 Aliases & Case Statements.
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
A subquery is a query inside another query. You can use it in SELECT, FROM, or WHERE clauses to solve complex problems step-by-step.
1. Subquery in WHERE Clause
Use this when you need to filter results based on another query.
SELECT name
FROM employees
WHERE department_id = (
SELECT id FROM departments WHERE name = 'Sales'
);
This finds all employees who work in the Sales department.
2. Subquery in SELECT Clause
This lets you fetch calculated or related values for each row.
SELECT name,
(SELECT AVG(salary) FROM employees) AS avg_salary
FROM employees;
Shows each employee’s name along with the company’s average salary.
3. Subquery in FROM Clause (Inline View)
Used when you want to treat the subquery like a temporary table.
SELECT department, total
FROM (
SELECT department, SUM(salary) AS total
FROM employees
GROUP BY department
) AS dept_summary;
This groups salaries by department in a subquery, then fetches from it.
Important:
- Always alias your subqueries (especially in the FROM clause).
- Avoid correlated subqueries if possible; they’re slower.
React with ❤️ if you want me to cover the next topic: 🏷 Aliases & Case Statements.
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤11👍8👏1
What does the following SQL query return?
SELECT name FROM employees WHERE department_id = ( SELECT id FROM departments WHERE name = 'HR' );
SELECT name FROM employees WHERE department_id = ( SELECT id FROM departments WHERE name = 'HR' );
Anonymous Quiz
4%
All employees from all departments
75%
All employees who work in the HR department
19%
The name of the HR department
1%
Employees with NULL department ID
👍13❤5
Data Analytics
📦 Subqueries & Nested Queries A subquery is a query inside another query. You can use it in SELECT, FROM, or WHERE clauses to solve complex problems step-by-step. 1. Subquery in WHERE Clause Use this when you need to filter results based on another query.…
🏷 Aliases & CASE Statements
1. Aliases (AS keyword)
Aliases let you rename columns or tables temporarily to make your output cleaner or more readable.
Column Alias Example:
SELECT first_name AS name, salary AS monthly_income
FROM employees;
You’ll see name and monthly_income as column headers instead of raw column names.
Table Alias Example:
SELECT e.name, d.name
FROM employees AS e
JOIN departments AS d ON e.department_id = d.id;
Here e and d are shortcuts for table names, making complex queries more readable.
2. CASE Statements
CASE is SQL’s way of doing if-else logic inside queries.
Example 1: Categorizing Data
SELECT name,
CASE
WHEN salary > 80000 THEN 'High'
WHEN salary BETWEEN 50000 AND 80000 THEN 'Medium'
ELSE 'Low'
END AS salary_category
FROM employees;
This assigns each employee a salary category.
Example 2: Conditional Aggregation
SELECT department,
COUNT(CASE WHEN gender = 'Male' THEN 1 END) AS male_count,
COUNT(CASE WHEN gender = 'Female' THEN 1 END) AS female_count
FROM employees
GROUP BY department;
Counts males and females per department.
Use aliases to simplify your SQL, and CASE when you need decision-making logic in queries.
React with ❤️ if you're excited for the next topic :🧾 Views & Indexes
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
1. Aliases (AS keyword)
Aliases let you rename columns or tables temporarily to make your output cleaner or more readable.
Column Alias Example:
SELECT first_name AS name, salary AS monthly_income
FROM employees;
You’ll see name and monthly_income as column headers instead of raw column names.
Table Alias Example:
SELECT e.name, d.name
FROM employees AS e
JOIN departments AS d ON e.department_id = d.id;
Here e and d are shortcuts for table names, making complex queries more readable.
2. CASE Statements
CASE is SQL’s way of doing if-else logic inside queries.
Example 1: Categorizing Data
SELECT name,
CASE
WHEN salary > 80000 THEN 'High'
WHEN salary BETWEEN 50000 AND 80000 THEN 'Medium'
ELSE 'Low'
END AS salary_category
FROM employees;
This assigns each employee a salary category.
Example 2: Conditional Aggregation
SELECT department,
COUNT(CASE WHEN gender = 'Male' THEN 1 END) AS male_count,
COUNT(CASE WHEN gender = 'Female' THEN 1 END) AS female_count
FROM employees
GROUP BY department;
Counts males and females per department.
Use aliases to simplify your SQL, and CASE when you need decision-making logic in queries.
React with ❤️ if you're excited for the next topic :🧾 Views & Indexes
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤22👍4
Here’s a quick quiz based on Aliases & CASE Statements:
Quiz Question: What will the following query output? SELECT name, CASE WHEN salary >= 100000 THEN 'Executive' ELSE 'Staff' END AS role FROM employees;
Quiz Question: What will the following query output? SELECT name, CASE WHEN salary >= 100000 THEN 'Executive' ELSE 'Staff' END AS role FROM employees;
Anonymous Quiz
16%
Only employees with salaries above 100000
8%
Only employees with salaries below 100000
68%
All employees with a new column named "role" categorizing them as 'Executive' or 'Staff'
8%
An error due to incorrect syntax
👍23❤2
Many people still aren't fully utilizing the power of Telegram.
There are numerous channels on Telegram that can help you find the latest job and internship opportunities?
Here are some of my top channel recommendations to help you get started 👇👇
Latest Jobs & Internships: https://news.1rj.ru/str/getjobss
Jobs Preparation Resources:
https://news.1rj.ru/str/jobinterviewsprep
Data Science Jobs:
https://news.1rj.ru/str/datasciencej
Interview Tips:
https://news.1rj.ru/str/Interview_Jobs
Data Analyst Jobs:
https://news.1rj.ru/str/jobs_SQL
AI Jobs:
https://news.1rj.ru/str/AIjobz
Remote Jobs:
https://news.1rj.ru/str/jobs_us_uk
FAANG Jobs:
https://news.1rj.ru/str/FAANGJob
Software Developer Jobs: https://news.1rj.ru/str/internshiptojobs
If you found this helpful, don’t forget to like, share, and follow for more resources that can boost your career journey!
Let me know if you know any other useful telegram channel
ENJOY LEARNING👍👍
There are numerous channels on Telegram that can help you find the latest job and internship opportunities?
Here are some of my top channel recommendations to help you get started 👇👇
Latest Jobs & Internships: https://news.1rj.ru/str/getjobss
Jobs Preparation Resources:
https://news.1rj.ru/str/jobinterviewsprep
Data Science Jobs:
https://news.1rj.ru/str/datasciencej
Interview Tips:
https://news.1rj.ru/str/Interview_Jobs
Data Analyst Jobs:
https://news.1rj.ru/str/jobs_SQL
AI Jobs:
https://news.1rj.ru/str/AIjobz
Remote Jobs:
https://news.1rj.ru/str/jobs_us_uk
FAANG Jobs:
https://news.1rj.ru/str/FAANGJob
Software Developer Jobs: https://news.1rj.ru/str/internshiptojobs
If you found this helpful, don’t forget to like, share, and follow for more resources that can boost your career journey!
Let me know if you know any other useful telegram channel
ENJOY LEARNING👍👍
❤18👍6🎉2
Data Analytics
🏷 Aliases & CASE Statements 1. Aliases (AS keyword) Aliases let you rename columns or tables temporarily to make your output cleaner or more readable. Column Alias Example: SELECT first_name AS name, salary AS monthly_income FROM employees; You’ll see…
Now, let’s dive into a couple of powerful but often overlooked SQL features:
🧾 Views & Indexes (Basics)
1. Views
A View is a virtual table based on a SQL query. It doesn’t store data itself — it just stores the query logic.
Why use Views?
- Simplifies complex queries
- Improves code reusability
- Adds a layer of security by hiding certain columns
Creating a View:
CREATE VIEW high_salary_employees AS
SELECT name, salary
FROM employees
WHERE salary > 80000;
Using the View:
SELECT * FROM high_salary_employees;
Updating a View:
CREATE OR REPLACE VIEW high_salary_employees AS
SELECT name, salary, department
FROM employees
WHERE salary > 80000;
2. Indexes
An Index is like a book’s table of contents — it helps the database find data faster, especially in large tables.
Why use Indexes?
- Speeds up SELECT queries
- Great for columns used in WHERE, JOIN, and ORDER BY
Creating an Index:
CREATE INDEX idx_employee_name ON employees(name);
Indexes can slow down INSERT, UPDATE, DELETE because they need to update the index too.
Don’t overuse them — only on frequently searched or joined columns.
React with ❤️ if you’re ready for the next interesting concept: 🧠 Common Table Expressions (CTEs).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
🧾 Views & Indexes (Basics)
1. Views
A View is a virtual table based on a SQL query. It doesn’t store data itself — it just stores the query logic.
Why use Views?
- Simplifies complex queries
- Improves code reusability
- Adds a layer of security by hiding certain columns
Creating a View:
CREATE VIEW high_salary_employees AS
SELECT name, salary
FROM employees
WHERE salary > 80000;
Using the View:
SELECT * FROM high_salary_employees;
Updating a View:
CREATE OR REPLACE VIEW high_salary_employees AS
SELECT name, salary, department
FROM employees
WHERE salary > 80000;
2. Indexes
An Index is like a book’s table of contents — it helps the database find data faster, especially in large tables.
Why use Indexes?
- Speeds up SELECT queries
- Great for columns used in WHERE, JOIN, and ORDER BY
Creating an Index:
CREATE INDEX idx_employee_name ON employees(name);
Indexes can slow down INSERT, UPDATE, DELETE because they need to update the index too.
Don’t overuse them — only on frequently searched or joined columns.
React with ❤️ if you’re ready for the next interesting concept: 🧠 Common Table Expressions (CTEs).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤17👍5👏1
Which of the following statements about Views is TRUE?
Anonymous Quiz
24%
A view stores a copy of data for faster access
6%
You cannot use WHERE clause in a view
62%
A view is a saved SQL query that acts like a virtual table
8%
Views automatically create indexes on the columns
👍15❤1
Data Analytics
Now, let’s dive into a couple of powerful but often overlooked SQL features: 🧾 Views & Indexes (Basics) 1. Views A View is a virtual table based on a SQL query. It doesn’t store data itself — it just stores the query logic. Why use Views? - Simplifies…
Here comes one of the cleanest and most powerful features in SQL:
🧠 Common Table Expressions (CTEs)
A CTE (Common Table Expression) is a temporary result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. It makes your queries more readable and modular, especially when dealing with complex logic.
Syntax:
WITH cte_name AS (
SELECT column1, column2
FROM table_name
WHERE condition
)
SELECT *
FROM cte_name;
Example: Let’s say we want to get the top 3 highest-paid employees from each department.
WITH ranked_employees AS (
SELECT name, department, salary,
ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS rank
FROM employees
)
SELECT *
FROM ranked_employees
WHERE rank <= 3;
Why to use CTEs:
- Easier to break down complex queries
- You can use them multiple times in the main query
- Readable and cleaner than subqueries
You can chain multiple CTEs together and even write recursive CTEs for hierarchical data.
React with ❤️ if you're excited for the next one: 🔄 Window Functions (ROW_NUMBER, RANK, PARTITION BY).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
🧠 Common Table Expressions (CTEs)
A CTE (Common Table Expression) is a temporary result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. It makes your queries more readable and modular, especially when dealing with complex logic.
Syntax:
WITH cte_name AS (
SELECT column1, column2
FROM table_name
WHERE condition
)
SELECT *
FROM cte_name;
Example: Let’s say we want to get the top 3 highest-paid employees from each department.
WITH ranked_employees AS (
SELECT name, department, salary,
ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS rank
FROM employees
)
SELECT *
FROM ranked_employees
WHERE rank <= 3;
Why to use CTEs:
- Easier to break down complex queries
- You can use them multiple times in the main query
- Readable and cleaner than subqueries
You can chain multiple CTEs together and even write recursive CTEs for hierarchical data.
React with ❤️ if you're excited for the next one: 🔄 Window Functions (ROW_NUMBER, RANK, PARTITION BY).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤11👍9🥰1👏1
What is the main advantage of using a Common Table Expression (CTE) in SQL?
Anonymous Quiz
16%
It permanently stores the result like a table
27%
It speeds up query execution automatically
52%
It simplifies and organizes complex queries
5%
It replaces the need for JOINs entirely
❤5👍3
Data Analytics
Here comes one of the cleanest and most powerful features in SQL: 🧠 Common Table Expressions (CTEs) A CTE (Common Table Expression) is a temporary result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. It makes your queries…
🔄 Window Functions (ROW_NUMBER, RANK, PARTITION BY)
Window functions perform calculations across rows related to the current row — but unlike GROUP BY, they don’t collapse your data!
They are super useful for running totals, rankings, and finding duplicates.
1. ROW_NUMBER()
Gives a unique number to each row within a partition of a result set.
SELECT name, department, salary,
ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS row_num
FROM employees;
Ranks employees by salary within each department.
2. RANK() vs DENSE_RANK()
RANK() leaves gaps after ties.
DENSE_RANK() doesn’t.
SELECT name, salary,
RANK() OVER (ORDER BY salary DESC) AS rank,
DENSE_RANK() OVER (ORDER BY salary DESC) AS dense_rank
FROM employees;
3. PARTITION BY
It’s like a GROUP BY, but for window functions.
SELECT department, name, salary,
AVG(salary) OVER (PARTITION BY department) AS dept_avg_salary
FROM employees;
This shows each employee's salary alongside the average salary of their department — without collapsing the rows.
Other Useful Window Functions:
NTILE(n) – Divides rows into n buckets
LAG() / LEAD() – Look at previous/next row’s value
SUM() / AVG() over a window – for running totals
React with ❤️ if you're pumped for the next one: ⚙️ Data Manipulation (INSERT, UPDATE, DELETE).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
Window functions perform calculations across rows related to the current row — but unlike GROUP BY, they don’t collapse your data!
They are super useful for running totals, rankings, and finding duplicates.
1. ROW_NUMBER()
Gives a unique number to each row within a partition of a result set.
SELECT name, department, salary,
ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS row_num
FROM employees;
Ranks employees by salary within each department.
2. RANK() vs DENSE_RANK()
RANK() leaves gaps after ties.
DENSE_RANK() doesn’t.
SELECT name, salary,
RANK() OVER (ORDER BY salary DESC) AS rank,
DENSE_RANK() OVER (ORDER BY salary DESC) AS dense_rank
FROM employees;
3. PARTITION BY
It’s like a GROUP BY, but for window functions.
SELECT department, name, salary,
AVG(salary) OVER (PARTITION BY department) AS dept_avg_salary
FROM employees;
This shows each employee's salary alongside the average salary of their department — without collapsing the rows.
Other Useful Window Functions:
NTILE(n) – Divides rows into n buckets
LAG() / LEAD() – Look at previous/next row’s value
SUM() / AVG() over a window – for running totals
React with ❤️ if you're pumped for the next one: ⚙️ Data Manipulation (INSERT, UPDATE, DELETE).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤12👍7
Which of the following SQL functions assigns a unique, sequential number to rows within a partition, without skipping any numbers, even if there are ties?
Anonymous Quiz
20%
RANK()
37%
DENSE_RANK()
39%
ROW_NUMBER()
4%
NTILE()
👍10❤2
Data Analytics
🔄 Window Functions (ROW_NUMBER, RANK, PARTITION BY) Window functions perform calculations across rows related to the current row — but unlike GROUP BY, they don’t collapse your data! They are super useful for running totals, rankings, and finding duplicates.…
Let’s now cover a hands-on and frequently used part of SQL:
⚙️ Data Manipulation (INSERT, UPDATE, DELETE)
Data Manipulation Language (DML) commands are used to add, modify, or remove data from your tables.
1. INSERT – Add new records to a table.
INSERT INTO employees (name, department, salary)
VALUES ('John Doe', 'HR', 60000);
Multiple rows:
INSERT INTO employees (name, department, salary)
VALUES
('Alice', 'IT', 70000),
('Bob', 'Finance', 65000);
2. UPDATE – Modify existing records.
UPDATE employees
SET salary = 75000
WHERE name = 'John Doe';
With multiple fields:
UPDATE employees
SET salary = 80000, department = 'IT'
WHERE id = 101;
Always use WHERE in UPDATE to avoid accidental mass updates.
3. DELETE – Remove records from a table.
DELETE FROM employees
WHERE department = 'Temporary';
Again, make sure to use WHERE — or you’ll delete all rows!
Pro Tips:
- Test your WHERE clause with a SELECT first.
- Use BEGIN TRANSACTION and ROLLBACK if supported — for safety.
React with ❤️ if you're ready to learn how to create and structure your database with: 🧱 Data Definition (CREATE, ALTER, DROP).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
⚙️ Data Manipulation (INSERT, UPDATE, DELETE)
Data Manipulation Language (DML) commands are used to add, modify, or remove data from your tables.
1. INSERT – Add new records to a table.
INSERT INTO employees (name, department, salary)
VALUES ('John Doe', 'HR', 60000);
Multiple rows:
INSERT INTO employees (name, department, salary)
VALUES
('Alice', 'IT', 70000),
('Bob', 'Finance', 65000);
2. UPDATE – Modify existing records.
UPDATE employees
SET salary = 75000
WHERE name = 'John Doe';
With multiple fields:
UPDATE employees
SET salary = 80000, department = 'IT'
WHERE id = 101;
Always use WHERE in UPDATE to avoid accidental mass updates.
3. DELETE – Remove records from a table.
DELETE FROM employees
WHERE department = 'Temporary';
Again, make sure to use WHERE — or you’ll delete all rows!
Pro Tips:
- Test your WHERE clause with a SELECT first.
- Use BEGIN TRANSACTION and ROLLBACK if supported — for safety.
React with ❤️ if you're ready to learn how to create and structure your database with: 🧱 Data Definition (CREATE, ALTER, DROP).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤21👍4
What will happen if you run the following SQL statement without a WHERE clause?
DELETE FROM employees;
DELETE FROM employees;
Anonymous Quiz
9%
Only one row will be deleted.
10%
Nothing will happen.
64%
All rows in the employees table will be deleted.
18%
It will throw an error.
❤9👍4
9 tips to master Power BI for Data Analysis:
📥 Learn to import data from various sources
🧹 Clean and transform data using Power Query
🧠 Understand relationships between tables using the data model
🧾 Write DAX formulas for calculated columns and measures
📊 Create interactive visuals: bar charts, slicers, maps, etc.
🎯 Use filters, slicers, and drill-through for deeper insights
📈 Build dashboards that tell a clear data story
🔄 Refresh and schedule your reports automatically
📚 Explore Power BI community and documentation for new tricks
Power BI Free Resources: https://news.1rj.ru/str/PowerBI_analyst
Hope it helps :)
#powerbi
📥 Learn to import data from various sources
🧹 Clean and transform data using Power Query
🧠 Understand relationships between tables using the data model
🧾 Write DAX formulas for calculated columns and measures
📊 Create interactive visuals: bar charts, slicers, maps, etc.
🎯 Use filters, slicers, and drill-through for deeper insights
📈 Build dashboards that tell a clear data story
🔄 Refresh and schedule your reports automatically
📚 Explore Power BI community and documentation for new tricks
Power BI Free Resources: https://news.1rj.ru/str/PowerBI_analyst
Hope it helps :)
#powerbi
❤8👍5
Data Analytics
Let’s now cover a hands-on and frequently used part of SQL: ⚙️ Data Manipulation (INSERT, UPDATE, DELETE) Data Manipulation Language (DML) commands are used to add, modify, or remove data from your tables. 1. INSERT – Add new records to a table. INSERT…
Let’s move on to the backbone of any SQL database:
🧱 Data Definition (CREATE, ALTER, DROP)
Data Definition Language (DDL) is used to define and manage database structures like tables, columns, and schemas.
1. CREATE – Used to create new tables, databases, or other objects.
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
department VARCHAR(50),
salary DECIMAL(10, 2)
);
You can also create other things like databases, indexes, or views:
CREATE DATABASE company_db;
2. ALTER – Modify an existing table’s structure.
Add a column:
ALTER TABLE employees
ADD date_of_joining DATE;
Modify column data type:
ALTER TABLE employees
ALTER COLUMN salary TYPE FLOAT;
Drop a column:
ALTER TABLE employees
DROP COLUMN date_of_joining;
3. DROP – Permanently delete a table, view, or database.
DROP TABLE employees;
Caution: This deletes everything — structure and data. Use with care!
Bonus: TRUNCATE
TRUNCATE TABLE employees;
Deletes all data from the table but keeps the structure intact. It's faster than DELETE but not recoverable.
React with ❤️ if you're ready for the next one: 🔐 Constraints & Relationships (PK, FK, UNIQUE, CHECK).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
🧱 Data Definition (CREATE, ALTER, DROP)
Data Definition Language (DDL) is used to define and manage database structures like tables, columns, and schemas.
1. CREATE – Used to create new tables, databases, or other objects.
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
department VARCHAR(50),
salary DECIMAL(10, 2)
);
You can also create other things like databases, indexes, or views:
CREATE DATABASE company_db;
2. ALTER – Modify an existing table’s structure.
Add a column:
ALTER TABLE employees
ADD date_of_joining DATE;
Modify column data type:
ALTER TABLE employees
ALTER COLUMN salary TYPE FLOAT;
Drop a column:
ALTER TABLE employees
DROP COLUMN date_of_joining;
3. DROP – Permanently delete a table, view, or database.
DROP TABLE employees;
Caution: This deletes everything — structure and data. Use with care!
Bonus: TRUNCATE
TRUNCATE TABLE employees;
Deletes all data from the table but keeps the structure intact. It's faster than DELETE but not recoverable.
React with ❤️ if you're ready for the next one: 🔐 Constraints & Relationships (PK, FK, UNIQUE, CHECK).
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤18👍3👏2