TGViewer
Channel Public Channel
SQL Programming Resources

SQL Programming Resources

@sqlanalyst

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
Subscribers
76.7K
Photos
597
Videos
1
Links
567

Showing posts older than #2481 ยท Back to latest

Older Posts 20 shown
Post #2480 4.66K
๐Ÿ”ฅ Now, Letโ€™s move to the next topic:

โœ… UNION & UNION ALL in SQL

๐Ÿง  1. What is UNION?
UNION is used to combine results from multiple SELECT queries.

"Merge data from two tables into one result.โ€

โšก 2. Rules for UNION
โœ” Same number of columns
โœ” Same datatype/order of columns

๐Ÿ“Š Example Tables

๐Ÿ‘จโ€๐Ÿ’ผ employeesโ‚‚024
name
โ€ข Amit
โ€ข Neha

๐Ÿ‘จโ€๐Ÿ’ผ employeesโ‚‚025
name
โ€ข Ravi
โ€ข Neha

๐Ÿ”ฅ 3. UNION Example

SELECT name FROM employees_2024
UNION
SELECT name FROM employees_2025;


โœ” Removes duplicates automatically

โœ… Result
name
โ€ข Amit
โ€ข Neha
โ€ข Ravi

โšก 4. UNION ALL

SELECT name FROM employees_2024
UNION ALL
SELECT name FROM employees_2025;


โœ” Keeps duplicates
โœ” Faster than UNION

โœ… Result
name
โ€ข Amit
โ€ข Neha
โ€ข Ravi
โ€ข Neha

๐Ÿ”ฅ 5. UNION vs UNION ALL

UNION
โ€ข Removes duplicates
โ€ข Slower
โ€ข Doesn't keep all rows

UNION ALL
โ€ข Doesn't remove duplicates
โ€ข Faster
โ€ข Keeps all rows

โšก 6. ORDER BY with UNION

SELECT name FROM employees_2024
UNION
SELECT name FROM employees_2025
ORDER BY name;


๐ŸŽฏ 7. Practice Tasks
1. Combine employee names using UNION
2. Combine employee names using UNION ALL
3. Identify duplicate removal
4. Sort UNION result using ORDER BY
5. Compare UNION vs UNION ALL output

โšก Mini Challenge ๐Ÿ”ฅ
๐Ÿ‘‰ Combine customer names from two branches and keep duplicates

๐Ÿ”ฅ Mini Challenge Solution ๐Ÿ’ฏ

๐Ÿ‘‰ Since duplicates should remain โ†’ use UNION ALL

โœ… Example Tables

๐Ÿข branch_a_customers
customer_name
โ€ข Amit
โ€ข Neha

๐Ÿข branch_b_customers
customer_name
โ€ข Ravi
โ€ข Neha

โœ… SQL Solution

SELECT customer_name
FROM branch_a_customers

UNION ALL

SELECT customer_name
FROM branch_b_customers;


โœ… Result
customer_name
โ€ข Amit
โ€ข Neha
โ€ข Ravi
โ€ข Neha

โœ” Duplicate Neha is preserved ๐Ÿ’ฏ

๐Ÿง  Why UNION ALL?
๐Ÿ‘‰ UNION โ†’ removes duplicates
๐Ÿ‘‰ UNION ALL โ†’ keeps duplicates + faster

Double Tap โค๏ธ For More
  • โค 9
Post #2479 4K
๐—ง๐—ผ๐—ฝ ๐Ÿฏ ๐—™๐—ฅ๐—˜๐—˜ ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐—œ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ! ๐Ÿš€๐Ÿ’ป

These FREE certification courses can help you build strong programming skills and stand out from the crowd ๐Ÿ‘‡

โœ… Free Learning Resources
โœ… Certificate Opportunities
โœ… Beginner Friendly
โœ… Boost Your Resume & Tech Skills

๐ŸŒŸ Perfect for students, freshers, aspiring developers, data analysts, and tech enthusiasts.

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/43DnP6S

๐Ÿ“Œ Start learning today and level up your career with Python!
  • โค 3
  • ๐Ÿ‘ 2
Post #2478 4.84K
If you're working with data pipelines, these repositories are very useful: ๐Ÿš€๐Ÿ“Š

ibis: A Python API that allows you to write queries once and run them on different data backends, such as DuckDB, BigQuery, and Snowflake. ๐Ÿ๐Ÿ”—
https://github.com/ibis-project/ibis

pygwalker: Instantly turns a DataFrame into an interactive UI for visual data exploration. ๐Ÿ“ˆ๐Ÿ–ฅ๏ธ
https://github.com/Kanaries/pygwalker

katana: A fast and scalable web crawler, often used for security testing and large-scale data collection/search. ๐Ÿ•ท๏ธ๐Ÿ”’
https://github.com/projectdiscovery/katana

Double Tap โค๏ธ For More Free Resources
  • โค 5
  • ๐Ÿ‘ 1
Post #2477 4.22K
๐——๐—ฎ๐˜๐—ฎ ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—š๐—ฒ๐—ป๐—”๐—œ ๐—ข๐—ป๐—น๐—ถ๐—ป๐—ฒ ๐—ช๐—ฒ๐—ฏ๐—ถ๐—ป๐—ฎ๐—ฟ ๐Ÿ˜

AI is replacing analysts who don't adapt.

Learn Data Analytics + GenAI with IBM & Microsoft certifications. Land your dream role with dedicated placement support.

๐ŸŽ“1200+ Hiring Partners. 128% avg hike. 35 LPA Highest CTC in Placements.

๐Ÿ’ซ๐—•๐—ผ๐—ผ๐—ธ ๐˜†๐—ผ๐˜‚๐—ฟ ๐—™๐—ฅ๐—˜๐—˜ ๐˜„๐—ฒ๐—ฏ๐—ถ๐—ป๐—ฎ๐—ฟ :-

https://pdlink.in/4uwBw3q

Hurry Up โ€โ™‚๏ธ! Limited seats are available.
  • โค 3
Post #2475 4.35K
๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€๐ŸŽ“

โœจ Learn In-Demand Tech Skills
โœจ Boost Your Resume & LinkedIn Profile
โœจ Improve Career Opportunities
โœจ Self-Paced Online Learning
โœจ Great for Freshers & Students

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/49p31Uh

๐Ÿ”ฅ Start learning today and prepare for high-paying tech careers with Microsoft free certification programs
  • โค 3
Post #2474 3.69K
๐Ÿ”ฅ Now, let's move to the next topic:

โœ… SQL Constraints

Essential for data integrity & important in interviews ๐Ÿ’ฏ

๐Ÿง  1. What are Constraints in SQL?
Constraints are rules applied on table columns
๐Ÿ‘‰ to maintain accurate & valid data

Think like this ๐Ÿ‘‡
๐Ÿ‘‰ โ€œDatabase safety rulesโ€

โšก 2. Why Use Constraints?
โœ” Prevent invalid data
โœ” Maintain consistency
โœ” Improve data integrity
โœ” Enforce relationships

๐Ÿ“Š Types of Constraints

NOT NULL
โ€ข Purpose: Prevent NULL values

UNIQUE
โ€ข Purpose: No duplicate values

PRIMARY KEY
โ€ข Purpose: Unique identifier

FOREIGN KEY
โ€ข Purpose: Create relationship

CHECK
โ€ข Purpose: Apply condition

DEFAULT
โ€ข Purpose: Set default value

๐Ÿ”ฅ 3. NOT NULL Constraint
๐Ÿ‘‰ Column cannot contain NULL

CREATE TABLE employees (
emp_id INT,
name VARCHAR(50) NOT NULL
);


๐Ÿ”ฅ 4. UNIQUE Constraint
๐Ÿ‘‰ Prevent duplicate values

CREATE TABLE users (
email VARCHAR(100) UNIQUE
);


๐Ÿ”ฅ 5. PRIMARY KEY
๐Ÿ‘‰ Unique + NOT NULL

CREATE TABLE employees (
emp_id INT PRIMARY KEY,
name VARCHAR(50)
);


โœ” Every row must have unique emp_id

๐Ÿ”ฅ 6. FOREIGN KEY
๐Ÿ‘‰ Creates relationship between tables

CREATE TABLE employees (
emp_id INT PRIMARY KEY,
dept_id INT,
FOREIGN KEY (dept_id)
REFERENCES departments(dept_id)
);


โœ” dept_id must exist in departments table

๐Ÿ”ฅ 7. CHECK Constraint
๐Ÿ‘‰ Restrict values using condition

CREATE TABLE employees (
salary INT CHECK (salary > 0)
);


โœ” Salary cannot be negative

๐Ÿ”ฅ 8. DEFAULT Constraint
๐Ÿ‘‰ Assign default value automatically

CREATE TABLE employees (
city VARCHAR(50) DEFAULT 'Pune'
);


๐ŸŽฏ 9. Practice Tasks
1. Create table using PRIMARY KEY
2. Add UNIQUE constraint on email
3. Create FOREIGN KEY relationship
4. Use CHECK for salary > 0
5. Add DEFAULT city value

โšก Mini Challenge ๐Ÿ”ฅ
๐Ÿ‘‰ Create students table with:
โ€ข student_id โ†’ PRIMARY KEY
โ€ข email โ†’ UNIQUE
โ€ข age > 18 using CHECK
โ€ข city default = 'Mumbai'

Double Tap โค๏ธ For More
  • โค 11
  • ๐Ÿ‘ 2
Post #2473 2.86K
๐—”๐—œ & ๐— ๐—Ÿ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ ๐—ฏ๐˜† ๐—–๐—–๐—˜, ๐—œ๐—œ๐—ง ๐— ๐—ฎ๐—ป๐—ฑ๐—ถ๐Ÿ˜

Freshers get 15 LPA Average Salary with AI & ML Skills!

- Eligibility: Open to everyone
- Duration: 6 Months
- Program Mode: Online
- Taught By: IIT Mandi Professors

90% Resumes without AI + ML skills are being rejected.

  ๐—”๐—ฝ๐—ฝ๐—น๐˜† ๐—ก๐—ผ๐˜„๐Ÿ‘‡ :- 

https://pdlink.in/4nmI024

Get Placement Assistance With 5000+ Companies
  • โค 1
Post #2472 3.19K
  • โค 4
Post #2471 3.06K
  • โค 2
Post #2470 3.19K
  • โค 1
Post #2469 3.4K
  • โค 1
Post #2468 3.2K
  • โค 1
Post #2467 3.49K
๐——๐—ฎ๐˜๐—ฎ ๐—ฆ๐—ฐ๐—ถ๐—ฒ๐—ป๐—ฐ๐—ฒ ๐˜„๐—ถ๐˜๐—ต ๐—”๐—œ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ | ๐Ÿญ๐Ÿฌ๐Ÿฌ% ๐—๐—ผ๐—ฏ ๐—”๐˜€๐˜€๐—ถ๐˜€๐˜๐—ฎ๐—ป๐—ฐ๐—ฒ๐Ÿ˜

Build Python, Machine Learning, and AI Skills

๐Ÿ’ซ60+ Hiring Drives Every Month | Receive 1-on-1 mentorship

12.65 Lakhs Highest Salary | 500+ Partner Companies

๐—•๐—ผ๐—ผ๐—ธ ๐—ฎ ๐—™๐—ฅ๐—˜๐—˜ ๐—ฆ๐—ฒ๐˜€๐˜€๐—ถ๐—ผ๐—ป :- ๐Ÿ‘‡:-

 Online :- https://pdlink.in/4fdWxJB

๐Ÿ”น Hyderabad :- https://pdlink.in/4kFhjn3

๐Ÿ”น Pune:-  https://pdlink.in/45p4GrC

๐Ÿ”น Noida :-  https://linkpd.in/DaNoida

Hurry Up ๐Ÿƒโ€โ™‚๏ธ! Limited seats are available.
  • โค 2
Post #2466 3.64K
๐Ÿ”ฅ Now, letโ€™s move to the next topic:

โœ… Denormalization in SQL

๐Ÿง  1. What is Denormalization?
Denormalization means
๐Ÿ‘‰ combining normalized tables
๐Ÿ‘‰ to improve query performance

Think like this ๐Ÿ‘‡
โœ… Normalization โ†’ reduce redundancy
โœ… Denormalization โ†’ improve speed

โšก 2. Why Use Denormalization?
โœ” Faster queries
โœ” Fewer JOIN operations
โœ” Better reporting performance

โŒ But:
- Data redundancy increases
- Updates become harder

๐Ÿ“Š Example (Normalized Structure)

๐Ÿ‘จโ€๐ŸŽ“ Students
student_id: 1
name: Amit

๐Ÿ“˜ Courses
course_id: 101
course: SQL

๐Ÿ“ Enrollment
student_id: 1
course_id: 101

๐Ÿ‘‰ Need JOINs to get full info

โšก Denormalized Structure
student_id: 1
name: Amit
course: SQL

โœ” Faster retrieval
โŒ Duplicate data possible

๐Ÿ”ฅ 3. Normalization vs Denormalization

Feature: Redundancy โ†’ Normalization: Low โ†’ Denormalization: High

Feature: Query Speed โ†’ Normalization: Slower โ†’ Denormalization: Faster

Feature: Storage โ†’ Normalization: Less โ†’ Denormalization: More

Feature: JOINs โ†’ Normalization: More โ†’ Denormalization: Fewer

โšก 4. Real-World Usage
โœ… Normalization Used In:
- Banking systems
- Transaction systems
- OLTP databases

โœ… Denormalization Used In:
- Reporting systems
- Dashboards
- Data warehouses

๐ŸŽฏ 5. Example Query

๐Ÿ‘‰ Normalized (requires JOIN)

SELECT s.name, c.course
FROM students s
JOIN enrollment e
ON s.student_id = e.student_id
JOIN courses c
ON e.course_id = c.course_id;


๐Ÿ‘‰ Denormalized
SELECT name, course
FROM student_courses;


โœ” Simpler & faster

๐ŸŽฏ 6. Practice Tasks
1. Identify normalized tables
2. Create denormalized version
3. Compare JOIN vs direct query
4. Find redundancy in denormalized table
5. Decide when denormalization is useful

โšก Mini Challenge ๐Ÿ”ฅ
๐Ÿ‘‰ Design a denormalized sales report table for faster dashboard queries

โœ… Pro Tips:
๐Ÿ‘‰ โ€œNormalization improves consistencyโ€
๐Ÿ‘‰ โ€œDenormalization improves performanceโ€

Double Tap โค๏ธ For More
  • โค 16
  • ๐Ÿ‘ 1
Post #2465 3.75K
  • โค 2
Post #2463 3.76K
  • โค 2
Post #2461 3.4K
  • โค 1
Older posts โ†’
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’