📁 SQL Practice with ORDER BY, WHERE & DISTINCT

🔃 Lab 2.1: ORDER BY, WHERE, DISTINCT in SQL

In this lab, we will learn how to sort and filter data using SQL's ORDER BY, WHERE, and DISTINCT clauses. We'll use a sample dataset with Bangladeshi employee names for realistic practice.

📁 Sample Employees Table

ID First Name Last Name Department Salary
101RakibHossainIT70000
102TamannaSultanaHR55000
103ImranAhmedIT80000
104NaeemIslamHR50000
105SharminJahanMarketing60000

đŸ§Ē SQL Practice Queries with Explanations

1. ORDER BY – Ascending Salary

SELECT * FROM employees
ORDER BY salary ASC;

This query lists all employees sorted by their salary from lowest to highest.

2. ORDER BY – Descending Salary

SELECT * FROM employees
ORDER BY salary DESC;

This will show the employees with the highest salary at the top.

3. WHERE – Filter by Department (IT)

SELECT * FROM employees
WHERE department = 'IT';

This query filters and shows only employees from the IT department.

4. WHERE – Salary Above 60,000

SELECT * FROM employees
WHERE salary > 60000;

This will return employees who earn more than 60,000.

5. DISTINCT – Unique Departments

SELECT DISTINCT department FROM employees;

Returns a list of unique department names without duplicates.

6. DISTINCT – Unique Salaries

SELECT DISTINCT salary FROM employees;

Returns a list of different salary values (no duplicates).

📌 Summary

  • ORDER BY – Sorts the result (ASC or DESC)
  • WHERE – Filters rows based on conditions
  • DISTINCT – Removes duplicate values
✅ Practice these to master basic data selection and sorting in SQL. Very useful for real-world data analysis and interview prep!
SQL ORDER BY, SQL WHERE clause, SQL DISTINCT example, SQL Bangla tutorial, SQL filtering, SQL sorting, SQL for beginners, SQL practice with Bangladesh dataset, SQL blogspot tutorial, SQL query examples

āĻ•োāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāχ:

āĻāĻ•āϟি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āϟ āĻ•āϰুāύ