unit-1
unit-1
SQL Query
Functions 1.1. Numeric, String and Date functions
1.2. Aggregate Functions
1.3. Sorting and Grouping the data
AVG()
COUNT()
FIRST()
LAST()
MAX()
MIN()
SUM()
select avg(grade)
from students
Students-Table
For Example:-
Marks:-
90
70
50
60
Ans:-90
Syntax:
SUBSTR('String',start-index,length_of_extracted_string)
Example:
SELECT SUBSTR('Database Management System', 9)
FROM DUAL;
Output:
Management System
Now()
SELECT Name, NOW() AS DateTime FROM Employee;
Format()
SELECT NAME, FORMAT(DATE, DD-MM-YYYY) FROM Employee;
5) POWER() Function
This numeric function is used to return the power of a given
expression.
Syntax: POWER(m, n)
Example:
SELECT POWER(2, 3) FROM DUAL;
Output:
8
SELECT *
FROM customers
ORDER BY Name ASC;
select *
from student
order by name, ssn desc
select count(*)
from takes
where ???