Professional Documents
Culture Documents
DBMS Exp 5
DBMS Exp 5
PRN:120A7016
DIV: B(SE-ECS)
EXPERIMENT NO. 5
AIM: Perform Simple queries, string manipulation operations and aggregate functions.
.
Or SUM (DISTINCT A): The sum of all unique values in the A column.
Or AVG (DISTINCT A): The average of all unique values in the A column.
Note that it does not make sense to specify DISTINCT in conjunction with MIN or
MAX(although SQL does not preclude this).
3) Displays all the sailors according to rating, if rating is same then sort according to
age.
GROUP BY and HAVING Clauses: - Thus far, aggregate operations are applied to all
(qualifying) rows in a relation. Often we want to apply aggregate operations to each of
a number of groups of rows in a relation, where the number of groups depends on the
relation instance. For this purpose we can use Group by clause.
GROUP BY: - Group by is used to make each a number of groups of rows in a relation,
where the number of groups depends on the relation instances. The general syntax is
GROUPING_LIST;
Ex: - Find the age of the youngest sailor for each rating level.
Ex: - Find the age of youngest sailor with age >= 18 for each rating with at least 2 such
sailors.
LIKE: The LIKE operator is used in a WHERE clause to search for a specified
pattern in a column.
There are two wildcards used in conjunction with the LIKE operator:
Examples:
2. selects all customers with a CustomerName that have "r" in the second
position:
Alias: The use of table aliases is to rename a table in a specific SQL statement. The
renaming is a temporary change and the actual table name does not change in the
database. The column aliases are used to rename a table's columns for the purpose of a
particular SQL query.
WHERE [condition];
FROM table_name
WHERE [condition];
Example:
Distinct: The SELECT DISTINCT statement is used to return only distinct (different)
values.
Code: