SQL 2
SQL 2
SQL 2
Operator Specifies
+ Addition
- Subtraction
* Multiplication
/ Division
() Enclosed operation
User Return the user name of select user from dual; system
the user currently logged
in
GREATEST Returns the greatest values select 52,30
from the given expression greatest(48,52,17),greatest
(10,29,30) from dual;
LEAST Returns the smallest values select 10
from the given expression least(10,20,50,20,30) from
dual;
Vsize Return the storage size of Select 2,5
expression in sql. vsize(12),vsize(‘india’)
from dual;
Conversion Function
Computer Civil
Engineer Engineer
Group of Engineers
Identifies Computer
Engineers, Civil
Engineers, Electrical
Engineers and
Mechanical Engineer
from these students Electrical Mechanical
Engineer Engineer
Group By clause
• It groups records based distinct values for specified
columns.
• In other words, it creates a group of distinct values
from available records.
• Syntax :
select column1,column2,aggregate function(argument)
from table name
group by column1,column2,…;
Example
• select s_city, sum(marks)"total marks" from student
group by s_city;
Output :-
S_CITY total marks
---------- -----------
junagadh 41
ahemdabad 74
rajkot 46
Example
• select s_branch, sum(marks)"total marks" from student
group by s_branch;
Computer
Engineers
Identifies the Students who
Group of Engineers are working in .NET
Technology only from the
result of group by clause
Having will
be use at that
time
Having clause
• When we want to put a filter data.
• It is used when we want to filters group based data
Difference
between where
with a specified condition.
and having clause
• It must appear within
?? an aggregate function
• Syntax :
Select column1,column2,aggregate
function(argument)
from tablename group by column1,column2,…
having condition;
Having clause
Identifies Computer
Engineers using group
by clause
Computer
Engineers
Identifies the Students who
Group of Engineers are working in .NET
Technology only from the
result of group by clause
Having will
be use at that
time
Example
• select s_branch, sum(marks)"total marks" from student group
by s_branch having s_branch='computer';