0% found this document useful (0 votes)
52 views5 pages

DDMS Lab

This lab report focuses on SQL operators, detailing arithmetic, comparison, logical, BETWEEN, LIKE, IN operators, and aggregate functions. Each section includes a description, general structure, and examples of SQL code for practical understanding. The report is submitted by Md. Mursalin Hasan Nirob to lecturer Sayefa Arafah on September 22, 2024.

Uploaded by

promihard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views5 pages

DDMS Lab

This lab report focuses on SQL operators, detailing arithmetic, comparison, logical, BETWEEN, LIKE, IN operators, and aggregate functions. Each section includes a description, general structure, and examples of SQL code for practical understanding. The report is submitted by Md. Mursalin Hasan Nirob to lecturer Sayefa Arafah on September 22, 2024.

Uploaded by

promihard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lab Report - 01

Course Title : Distributed Database Management System Lab.


Course Code : CSE-418
Report Name : SQL Operators

Submitted By : Submitted To :
Name : Md. Mursalin Hasan Nirob Name : Sayefa Arafah
ID No : 21225103423 Arpona
Lecturer
Intake : 49
Department of : CSE
Section : 10
Bangladesh University of Business &
Program : B.Sc. Engg. in CSE
Technology

Date of Submission: 22/09/2024


1. Topic Name: SQL Arithmetic Operators

1.2. Topic Description:

SQL Arithmetic operators are used to perform mathematical operations on numeric data
in SQL queries. These operators are used to add, subtract, multiply, divide, or find the
remainder (modulus) of two or more numeric values in SQL statements.

1.3. General Structure of SQL for Arithmetic Operators:

Sql code:
SELECT column_name,
column_name + column_name AS alias_name,
column_name - column_name AS alias_name,
column_name * column_name AS alias_name,
column_name / column_name AS alias_name,
column_name % column_name AS alias_name
FROM table_name;

1.4. Example:

Sql code:
SELECT product_id,
price,
quantity,
price * quantity AS total_cost,
price + 10 AS increased_price
FROM products;

2. Topic Name: SQL Comparison Operators

2.1. Topic Description:

SQL Comparison operators are used to compare two expressions. These operators
help in filtering the result sets by using conditions. They include operators such as =, !=,
>, <, >=, <=, and <>.

2.2. General Structure of SQL for Comparison Operators:

Sql code:
SELECT column_name
FROM table_name
WHERE column_name = value OR
column_name != value OR
column_name > value OR
column_name < value OR
column_name >= value OR
column_name <= value OR
column_name <> value;

2.3. Example:

Sql code:
SELECT employee_id,
employee_name,
salary
FROM employees
WHERE salary > 5000;

3. Topic Name: SQL Logical Operators

3.1. Topic Description:

SQL Logical operators are used to combine multiple conditions in a WHERE clause.
These operators include AND, OR, and NOT to form complex queries.

3.2. General Structure of SQL for Logical Operators:

Sql code:
SELECT column_name
FROM table_name
WHERE condition1 AND condition2 OR
condition3 OR NOT condition4;

3.3. Example:

Sql code:
SELECT employee_id,
employee_name,
department
FROM employees
WHERE department = 'HR' AND salary > 4000;

4. Topic Name: SQL BETWEEN Operator

4.1. Topic Description:

The BETWEEN operator is used to filter the result set within a certain range. It is used
in a WHERE clause to check if a value lies between two given values.
4.2. General Structure of SQL for BETWEEN Operator:

Sql code:
SELECT column_name
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

4.3. Example:

Sql code:
SELECT employee_id,
employee_name,
age
FROM employees
WHERE age BETWEEN 25 AND 35;

5. Topic Name: SQL LIKE Operator

5.1. Topic Description:

The LIKE operator is used in a WHERE clause to search for a specified pattern in a
column. It is often used with wildcard characters (% and _) to match specific patterns.

5.2. General Structure of SQL for LIKE Operator:

Sql code:
SELECT column_name
FROM table_name
WHERE column_name LIKE pattern;

5.3. Example:

Sql code:
SELECT customer_id,
customer_name
FROM customers
WHERE customer_name LIKE 'A%';

6. Topic Name: SQL IN Operator

6.1. Topic Description:

The IN operator allows you to specify multiple values in a WHERE clause. It is an


efficient way to check if a value matches any value in a list of possible values.
6.2. General Structure of SQL for IN Operator:

Sql code:
SELECT column_name
FROM table_name
WHERE column_name IN (value1, value2, value3, ...);

6.3. Example:

Sql code:
SELECT order_id,
product_name
FROM orders
WHERE product_name IN ('Laptop', 'Smartphone', 'Tablet');

7. Topic Name: SQL Aggregate Functions (COUNT, SUM, AVG, MIN, MAX)

7.1. Topic Description:

SQL aggregate functions are used to perform calculations on multiple rows of a column.
Common aggregate functions include COUNT(), SUM(), AVG(), MIN(), and MAX().

7.2. General Structure of SQL for Aggregate Functions:

Sql code:
SELECT aggregate_function(column_name)
FROM table_name
WHERE condition;

7.3. Example:

Sql code:
SELECT AVG(salary) AS average_salary
FROM employees
WHERE department = 'IT';

You might also like