Data Analytics – Telegram
Data Analytics
108K subscribers
126 photos
2 files
791 links
Perfect channel to learn Data Analytics

Learn SQL, Python, Alteryx, Tableau, Power BI and many more

For Promotions: @coderfun @love_data
Download Telegram
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 :)
17👍5👏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 :)
11👍9🥰1👏1
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 :)
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()
👍102
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 :)
21👍4
What will happen if you run the following SQL statement without a WHERE clause?

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
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 :)
18👍3👏2
Data Analytics
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…
🔐 Constraints & Relationships (PK, FK, UNIQUE, CHECK)

Constraints are rules applied to columns to ensure valid and consistent data in your tables.


1. PRIMARY KEY (PK)
Uniquely identifies each row in a table.

Only one per table

Cannot be NULL

Often applied to an id column


CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100)
);


2. FOREIGN KEY (FK)
Establishes a relationship between tables.
It links a column to the PRIMARY KEY of another table.

CREATE TABLE departments (
dept_id INT PRIMARY KEY,
dept_name VARCHAR(50)
);

CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
dept_id INT,
FOREIGN KEY (dept_id) REFERENCES departments(dept_id)
);

Now, employees.dept_id must match a valid departments.dept_id.


3. UNIQUE
Ensures that all values in a column are different (can have one NULL if not restricted).

CREATE TABLE users (
user_id INT PRIMARY KEY,
email VARCHAR(100) UNIQUE
);


4. CHECK
Ensures a condition is true for data being inserted or updated.

CREATE TABLE products (
id INT PRIMARY KEY,
price DECIMAL(10, 2),
CHECK (price > 0)
);


5. NOT NULL
Prevents NULL values in a column.

CREATE TABLE orders (
order_id INT PRIMARY KEY,
product_name VARCHAR(100) NOT NULL
);

Using constraints helps keep your data clean, accurate, and relational.

React with ❤️ if you're ready for the final (and most practical) chapter: 🧪 Real-world SQL Scenarios & Challenges.

Share with credits: https://news.1rj.ru/str/sqlspecialist

Hope it helps :)
13👍3👏1
You have a users table where each user must have a unique email address, and emails cannot be NULL.

Which constraint(s) should you apply to the email column?
Anonymous Quiz
36%
PRIMARY KEY
21%
UNIQUE
9%
NOT NULL
34%
Both UNIQUE and NOT NULL
5👍2
Data Analytics
You have a users table where each user must have a unique email address, and emails cannot be NULL.

Which constraint(s) should you apply to the email column?
Most of you responded with first option PRIMARY KEY

Yes, a PRIMARY KEY does enforce: Uniqueness & NOT NULL


So technically, it's correct — making email a primary key will satisfy the condition that emails must be unique & not null


But... here’s the catch:

In real-world database design, email is rarely used as a primary key, because:

- It can change (users may update emails).

- It’s not an ideal unique identifier like a user_id (which is usually an auto-incrementing integer).

Using email as PK can make foreign key relationships messy and inefficient, so we'll have to explicitly use UNIQUE & NOT NULL constraints

Hope it clear most of the doubts :)
👍1712👏1
Data Analytics
🔐 Constraints & Relationships (PK, FK, UNIQUE, CHECK) Constraints are rules applied to columns to ensure valid and consistent data in your tables. 1. PRIMARY KEY (PK) Uniquely identifies each row in a table. Only one per table Cannot be NULL Often applied…
🧪 Real-world SQL Scenarios & Challenges

Let’s dive into the types of real-world problems you’ll encounter as a data analyst, data scientist , data engineer, or developer.


1. Finding Duplicates

SELECT name, COUNT(*)
FROM employees
GROUP BY name
HAVING COUNT(*) > 1;

Perfect for data cleaning and validation tasks.


2. Get the Second Highest Salary

SELECT MAX(salary) AS second_highest
FROM employees
WHERE salary < (
SELECT MAX(salary)
FROM employees
);


3. Running Totals

SELECT name, salary,
SUM(salary) OVER (ORDER BY id) AS running_total
FROM employees;

Essential in dashboards and financial reports.


4. Customers with No Orders

SELECT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE o.order_id IS NULL;

Very common in e-commerce or CRM platforms.


5. Monthly Aggregates

SELECT DATE_TRUNC('month', order_date) AS month,
COUNT(*) AS total_orders
FROM orders
GROUP BY month
ORDER BY month;

Great for trends and time-based reporting.


6. Pivot-like Output (Using CASE)

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;

Super useful for dashboards and insights.


7. Recursive Queries (Org Hierarchy or Tree)

WITH RECURSIVE employee_tree AS (
SELECT id, name, manager_id
FROM employees
WHERE manager_id IS NULL

UNION ALL

SELECT e.id, e.name, e.manager_id
FROM employees e
INNER JOIN employee_tree et ON e.manager_id = et.id
)
SELECT * FROM employee_tree;

Used in advanced data modeling and tree structures.


You don’t just need to know how SQL works — you need to know when to use it smartly!

React with ❤️ if you’d like me to explain more data analytics topics

Share with credits: https://news.1rj.ru/str/sqlspecialist

SQL Roadmap: https://news.1rj.ru/str/sqlspecialist/1340

Hope it helps :)
21👍4🥰1
What does the following query return?

SELECT MAX(salary) AS second_highest FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
Anonymous Quiz
15%
The highest salary
77%
The second-highest salary
3%
The lowest salary
5%
All salaries in descending order
👍74👏1
🔰 Power BI Roadmap for Beginners

├── 🧠 What is Power BI & Why Use It
├── 🧩 Power BI Components (Desktop, Service, Mobile)
├── 🔌 Connecting to Data Sources (Excel, SQL, Web, etc.)
├── 🧹 Power Query Editor (Data Cleaning & Transformation)
├── 🧱 Data Modeling (Relationships, Star & Snowflake Schema)
├── 📐 DAX Basics (Calculated Columns & Measures)
├── Important DAX Functions (SUM, CALCULATE, FILTER, etc.)
├── 📊 Creating Visuals (Bar, Pie, Table, Matrix, etc.)
├── 🎨 Visual Customizations (Themes, Tooltips, Conditional Formatting)
├── 📎 Bookmarks & Buttons (Navigation & Interactivity)
├── 📆 Time Intelligence in DAX (YTD, MTD, Previous Month, etc.)
├── 📊 Drill Through, Drill Down & Hierarchies
├── Performance Optimization Tips (Model Size, DAX, etc.)
├── 🛡 Row-Level Security (RLS)
├── ☁️ Publishing to Power BI Service
├── 🔄 Scheduled Refresh & Gateways
├── 👥 Sharing & Collaboration (Workspaces, Apps, Access)
├── 🧪 Real-World Projects & Dashboard Challenges

React with ❤️ for the detailed explanation of each topic

Share with credits: https://news.1rj.ru/str/sqlspecialist

SQL Roadmap: https://news.1rj.ru/str/sqlspecialist/1340

Hope it helps :)
20👍2👏1
🔰 Python Roadmap for Beginners

├── 🐍 Introduction to Python
├── 🧾 Installing Python & Setting Up VS Code / Jupyter
├── ✍️ Python Syntax & Indentation Basics
├── 🔤 Variables, Data Types (int, float, str, bool)
├── Operators (Arithmetic, Comparison, Logical)
├── 🔁 Conditional Statements (if, elif, else)
├── 🔄 Loops (for, while, break, continue)
├── 🧰 Functions (def, return, args, kwargs)
├── 📦 Built-in Data Structures (List, Tuple, Set, Dictionary)
├── 🧠 List Comprehension & Dictionary Comprehension
├── 📂 File Handling (read, write, with open)
├── 🐞 Error Handling (try, except, finally)
├── 🧱 Modules & Packages (import, pip install)
├── 📊 Working with Libraries (NumPy, Pandas, Matplotlib)
├── 🧹 Data Cleaning with Pandas
├── 🧪 Exploratory Data Analysis (EDA)
├── 🤖 Intro to OOP in Python (Class, Objects, Inheritance)
├── 🧠 Real-World Python Projects & Challenges

SQL Roadmap: https://news.1rj.ru/str/sqlspecialist/1340

Power BI Roadmap: https://news.1rj.ru/str/sqlspecialist/1397

Python Resources: https://news.1rj.ru/str/pythonproz

Hope it helps :)
👍54
Let's start with the first Python Concept today

1. Data Types & Data Structures

Before you analyze anything, you need to organize and store your data properly. Python offers four main data structures that every data analyst must master.

Lists ([])
A list is an ordered collection of items that can be changed (mutable).

Example:

scores = [85, 90, 78, 92]
print(scores[0]) # Output: 85

Use lists to store rows of data, filtered results, or time-series points.

Tuples (())
Tuples are like lists but immutable — once created, they can't be modified.

Example :

coords = (12.97, 77.59)

Use them when data should not change, like a fixed location or record.

Dictionaries ({})
Dictionaries store data in key-value pairs. They’re extremely useful when dealing with structured data.

Example:

person = {'name': 'Alice', 'age': 30}
print(person['name']) # Output: Alice

Use dictionaries for JSON data, mapping columns, or creating summary statistics.

Sets (set())
Sets are unordered collections with no duplicate values.

Example:

departments = set(['Sales', 'HR', 'Sales'])
print(departments) # Output: {'Sales', 'HR'}

Use sets when you need to find unique values in a dataset.

Here are some important points to remember:

- Lists help you store sequences like rows or values from a column.

- Dictionaries are great for quick lookups and mappings.

- Sets are useful when working with unique entries, like distinct categories.

- Tuples protect data from accidental modification.


You’ll use these structures every day with pandas. For example, each row in a DataFrame can be treated like a dictionary, and columns often act like lists.

React with ♥️ if you want me to cover next important Python concept Loops & Conditions.

Important Python Concepts: https://news.1rj.ru/str/sqlspecialist/749

Data Analyst Jobs: https://whatsapp.com/channel/0029Vaxjq5a4dTnKNrdeiZ0J

Hope it helps :)
23👍10
Data Analytics
Let's start with the first Python Concept today 1. Data Types & Data Structures Before you analyze anything, you need to organize and store your data properly. Python offers four main data structures that every data analyst must master. Lists ([]) A list…
Now, let’s move to the next important Python concept: Loops & Conditional Statements

Once your data is stored in a list, dictionary, or any structure, you’ll often want to loop through it or perform actions based on specific conditions.

Conditional Statements (if, elif, else)
These allow your program to make decisions based on certain conditions.

*Example* :

age = 25
if age >= 18:
print("Adult")
else:
print("Minor")

This code checks if age is 18 or more. If yes, it prints “Adult”. If not, it prints “Minor”.

Use this when:

- You’re filtering data based on certain conditions

- You want to handle missing values or outliers differently

- You want different results for different input categories


Loops (for, while)
Loops help you automate repetitive tasks.

In data analytics, this is especially useful for cleaning and transforming data.

Example (using for):

scores = [45, 67, 89, 90]
for score in scores:
if score >= 50:
print("Pass")
else:
print("Fail")

It loops through each number in the scores list.

If the score is 50 or more, it prints “Pass”.

Otherwise, it prints “Fail”.

So the output will be:

Fail
Pass
Pass
Pass


Example (using while):

count = 0
while count < 3:
print("Loading...")
count += 1

This starts with count = 0.

It keeps printing “Loading...” until count reaches 3.

After each loop, it adds 1 to count.
So it prints “Loading...” three times.


Real Use-Cases in Data Analytics:

- Looping through rows to clean or validate data

- Using conditions to flag anomalies or classify data

- Automating repetitive logic like formatting strings, checking for nulls, or recalculating columns


*Extras – break and continue:*
These help control your loop.

- break stops the loop

- continue skips the current iteration

Example:
for val in [1, 2, 0, 3]:
if val == 0:
continue
print(10 / val)


When it hits 0, it skips the division (to avoid dividing by zero).

For other numbers, it divides 10 by the value and prints it.


So the output is:

10.0
5.0
3.3333333333333335


While loops and conditionals are essential, you'll use them less directly when working with pandas — but understanding how they work under the hood helps you write better, faster code.

React with ♥️ if you're ready for the next important concept: Functions in Python

Python Data Structures: https://news.1rj.ru/str/sqlspecialist/1400

Python Roadmap: https://whatsapp.com/channel/0029VaGgzAk72WTmQFERKh02/459

Data Analyst Jobs: https://whatsapp.com/channel/0029Vaxjq5a4dTnKNrdeiZ0J

Hope it helps :)
7👍6
Data Analytics
Now, let’s move to the next important Python concept: Loops & Conditional Statements Once your data is stored in a list, dictionary, or any structure, you’ll often want to loop through it or perform actions based on specific conditions. Conditional Statements…
Now let’s move to the most powerful concepts in Python:

Functions – Write Once, Use Forever

Think of functions as your personal data assistant. They allow you to group a set of instructions under a name — and run that code whenever you need it, with just one line!


You’ll often repeat data cleaning steps (e.g., removing nulls, formatting dates) using Functions.

Functions make your code cleaner, reusable, and scalable.

You can also pass parameters to make functions more flexible.


*Basic Function Structure**

def greet(name):
print(f"Hello, {name}!")

What it does:
This defines a function called greet that takes one input (name) and prints a greeting.

When you call it like this:

greet("Alice")

Output:

Hello, Alice!


Real-Life Example:

Clean Column Names:

def clean_column(col_name):
return col_name.strip().lower().replace(" ", "_")


What it does:

.strip() removes extra spaces

.lower() makes everything lowercase

.replace(" ", "_") replaces spaces with underscores


Use-case :
If your dataset has messy column names like " Total Sales ", this function will turn it into "total_sales".

Function with Multiple Parameters

def calculate_discount(price, discount_percent):
return price - (price * discount_percent / 100)


What it does:
Takes in a price and discount percent, and returns the discounted price.

Example :

final_price = calculate_discount(200, 10)
print(final_price)

Output:

180.0


Reusability in Projects

Let’s say you’re working with sales data and you need to:

- Clean up strings

- Convert dates

- Format currency


You can create a function for each, and call them anytime you need across multiple projects. Saves hours in the long run.

React with ❤️ if you are ready for the next important concept: Lambda Functions in Python

Python Data Structures: https://news.1rj.ru/str/sqlspecialist/1400

Data Analyst Interview: https://whatsapp.com/channel/0029Vazm2S1Ae5VuwOzV1v1h

Data Analyst Jobs: https://whatsapp.com/channel/0029Vaxjq5a4dTnKNrdeiZ0J

Hope it helps :)
6👍5