๐๏ธ SQL Programming
1. What is SQL?
SQL stands for Structured Query Language. It is used to communicate with databases and work with stored data.
You can use SQL to:
โ Retrieve data
โ Filter data
โ Analyze data
โ Insert data
โ Update data
โ Delete data
2. SELECT
Used to retrieve data from a table.
SELECT name, salary
FROM employees;
SELECT โ columns you want
FROM โ table you want data from
To get all columns:
SELECT *
FROM employees;
3. WHERE
Used to filter rows.
SELECT *
FROM employees
WHERE salary > 50000;
Common operators:
= Equal
Greater than
< Less than
= Greater than or equal
<= Less than or equal
<> Not equal
4. AND, OR, NOT
Used to combine conditions.
SELECT *
FROM employees
WHERE salary > 50000
AND department = 'IT';
AND โ both conditions must be true.
SELECT *
FROM employees
WHERE department = 'IT'
OR department = 'HR';
OR โ at least one condition must be true.
5. ORDER BY
Used to sort your results.
SELECT *
FROM employees
ORDER BY salary DESC;
ASC โ Lowest to highest
DESC โ Highest to lowest
6. DISTINCT
Used to remove duplicate values.
SELECT DISTINCT department
FROM employees;
7. LIMIT
Used to restrict the number of rows returned.
SELECT *
FROM employees
LIMIT 10;
Note: Some databases use TOP or FETCH.
8. Aggregate Functions
Used to perform calculations on multiple rows.
COUNT() -- Count
SUM() -- Total
AVG() -- Average
MIN() -- Minimum
MAX() -- Maximum
Example:
SELECT AVG(salary)
FROM employees;
9. GROUP BY
Used to create groups and calculate results for each group.
SELECT
department,
AVG(salary) AS average_salary
FROM employees
GROUP BY department;
10. HAVING
Used to filter grouped results.
SELECT
department,
AVG(salary) AS average_salary
FROM employees
GROUP BY department
HAVING AVG(salary) > 70000;
WHERE โ filters rows
HAVING โ filters groups
๐ Python โ Beginner Fundamentals
1. What is Python?
Python is a general-purpose programming language used for:
โ Data Analytics
โ Automation
โ AI & Machine Learning
โ Data Engineering
โ Web Development
2. Variables
Variables store values.
name = "Alex"
age = 25
salary = 50000
3. Data Types
Important beginner data types:
name = "Alex" # str
age = 25 # int
salary = 50000.5 # float
active = True # bool
type(age)
4. Strings
Strings represent text.
name = "Python"
name.upper() # PYTHON
name.lower() # python
name.strip() # removes spaces
5. Numbers
Python supports integers and floating-point numbers.
age = 25
price = 99.50
10 + 5 # Addition
10 - 5 # Subtraction
10 * 5 # Multiplication
10 / 5 # Division
10 % 3 # Remainder
10 ** 2 # Power
6. Boolean
Boolean values represent True or False.
is_logged_in = True
7. Lists
Lists store multiple values in an ordered collection.
numbers = [10, 20, 30, 40]
numbers[0] # Output: 10
Python indexing starts from 0.
8. Dictionaries
Dictionaries store data as key-value pairs.