Escolar Documentos
Profissional Documentos
Cultura Documentos
(i) Character
(ii) Number
(iii) Date
(iv) Conversion
(v) General
Character Functions
•
• length(x)
It returns the length of the string x.
Example:
SQL> Select LENGTH ('Ipso Facto') ergo FROM dual;
• ltrim(string[,char(s)])
It removes all the blank spaces from the left side of the
string if no char is specified. If we give a char, then it
removes the leading occurrences of that character from the
string.
• Translate(char,find,new)
Syntax:
count([distinct|all]column name)
Example:
1. Count the number of employees in the emp table.
Example:
List the total salary paid to the employees in the emp table.
Example:
Example:
List the minimum salary in the emp table .
Example:
List the maximum salary and commission in the emp table .
Example
DEPTNO SUM(SAL)
10 2916.6667
20 2175
30 1566.6667
Here is how this SELECT statement, containing a GROUP BY clause,
is evaluated:
10 3
20 5
30 6
Note:
Any column or expression in the SELECT list that is not an
aggregate function must be in the GROUP By clause.
Restricting Group Results
In the syntax:
HAVING clause restricts the groups of rows returned to those
groups for which the specified condition is TRUE
The Oracle Server performs the following steps when you use the
HAVING clause:
• Rows are grouped
• The group function is applied to the group.
• The groups that match the criteria in the HAVING clause are
displayed.
DEPTNO MAX(SAL)
10 5000
20 3000
Use of WHERE clause with GROUP BY clause
List the total salary, maximum and minimum salary and the average
salary of employees job wise, for department number 20 and
display only those rows having average salary greater than 1000
JOB PAYROLL
ANALYST 6000
MANAGER 8275
The above query displays the job title and total monthly salary for
each job title with a total payroll exceeding Rs.5000. The example
excludes salespeople and sorts the list by the total monthly salary.
Display total no of suppliers supplying red part
Display total qty supplied by by each supplier