SlideShare a Scribd company logo
SQL Functions
&
Operators
CS2258 – Database Management Systems Lab
R. Mohan Kumar
Assistant Professor / CSE
Saranathan College of Engineering
SQL Functions
 Numeric Functions
 Date Functions
 Text Functions
CS2258 – Database Management Systems Lab
Syntax
select <function_name> from dual;
2
Numeric Functions
CS2258 – Database Management Systems Lab
FUNCTION NAME DESCRIPTION
ABS(x) Absolute value of the number “x”
CEIL(x) Integer value that is greater than (or) equal to “x”
FLOOR(x) Integer value that is lesser than (or) equal to “x”
TRUNC(x,y) Truncate values of “x” upto “y” decimal places.
ROUND(x,y) Rounded off value of “x” upto “y” decimal places.
1 of 5
3
Numeric Functions
CS2258 – Database Management Systems Lab
FUNCTION NAME DESCRIPTION
MOD(x,y) Returns the result of X % Y (remainder)
POWER(x,y) Returns the value of X ^ Y
SQRT(x) Returns the square root value of X
LOG(x) Returns the Base 10 logarithm of X
SIGN(x) 1 if X is POSITIVE ; -1 if X is NEGATIVE ; 0 if X is ZERO
2 of 5
4
Numeric Functions
CS2258 – Database Management Systems Lab
FUNCTION NAME DESCRIPTION
SIN(x) Returns the Sine value of X
COS(x) Returns the Cosine value of X
TAN(x) Returns the Tangent value of X
EXP(x) E raised to X exponent
LN(x) Returns the Natural Logarithm of X
3 of 5
5
Numeric Functions
CS2258 – Database Management Systems Lab
FUNCTION NAME DESCRIPTION
MAX()
It selects the MAXIMUM value in the specified column.
Syntax:
Select MAX(<col_name>) from <table_name>;
MIN()
It selects the MINIMUM value in the specified column.
Syntax:
Select MIN(<col_name>) from <table_name>;
MEDIAN()
It returns the MEDIAN of all values in the given
column.
Syntax:
Select MEDIAN(<col_name>) from <table_name>;
4 of 5
6
Numeric Functions
CS2258 – Database Management Systems Lab
FUNCTION NAME DESCRIPTION
AVG()
It returns the average of all values in the given column.
Syntax:
Select AVG(<col_name>) from <table_name>;
SUM()
It returns the sum of all values in the given column.
Syntax:
Select SUM(<col_name>) from <table_name>;
COUNT()
It returns the no. of rows in the given column.
Syntax:
Select COUNT(<col_name>) from <table_name>;
5 of 5
7
Date Functions
FUNCTION NAME DESCRIPTION
SYSDATE Returns the systems current date.
ADD_MONTHS(date,n)
Returns a date value after adding in months
to the “date”.
MONTHS_BETWEEN(x1,x2)
Returns the number of months between dates
x1 and x2.
NEXTDAY(x, weekday)
Returns the next date of the “weekday” on or
after “x” occurs.
LAST_DAY(x) Returns the last date of the particular month.
CS2258 – Database Management Systems Lab
1 of 2
8
Date Functions
FUNCTION NAME DESCRIPTION
SysTimeStamp
Returns the system date in TIMESTAMP
format.
To_char(date,format)
Returns the date value in given format.
Syntax:
Select to_char(sysdate,’mm/dd/yy’)
from dual;
CS2258 – Database Management Systems Lab
2 of 2
9
String / Text Functions
FUNCTION NAME DESCRIPTION
UPPER(x) It converts the string ‘X’ to UPPER case
LOWER(x) It converts the string ‘X’ to LOWER case
RTRIM(x,y)
It returns the string after trimming all
occurrence of sub string ‘y’ from right side of
the input string ‘X’.
LTRIM(x,y)
It returns the string after trimming all
occurrence of sub string ‘y’ from left side of
the input string ‘X’.
LENGTH(x) Returns the length of the input string ‘X’
CS2258 – Database Management Systems Lab
1 of 2
10
String / Text Functions
FUNCTION NAME DESCRIPTION
INITCAP(x)
It converts the first character of the input
string to UPPER case.
SUBSTR(x,m,n)
Returns the substring of given string starting
from position integer ‘m’ and length integer
‘n’.
TRANSLATE(x,new,old)
It converts the string by substituting the new
string in the place of old string.
ASCII(c) Returns the ASCII value of the character ‘c’.
CHR(number)
Returns the character for a ASCII value
‘number’.
CS2258 – Database Management Systems Lab
2 of 2
11
Operators
 Arithmetic Operators
+ , - , * , /
 Comparison Operators
= , != , <, <=, >, >=
Like, In, Between And , Is Null
 Logical Operators
OR, AND, NOT
CS2258 – Database Management Systems Lab 12
Operators usage
 Arithmetic Operator
select 2 + 3 from dual;
select 10 - 5 from dual;
select salary + allowance from worker;
salary & allowance are the attributes of worker table.
update customer set balance = balance + balance * 0.075;
CS2258 – Database Management Systems Lab 13
Operators usage
 Comparison Operator
select * from customer where amount = 10000;
select * from customer where amount < 500;
select * from customer where age > 68;
update customer set interest_rate = 0.0925
where age >= 68;
delete from customer where balance <= 50;
CS2258 – Database Management Systems Lab 14
Operators usage
 Comparison Operator
select * from customer where cname LIKE ‘a%;
select * from customer where cname LIKE ‘%er;
select * from customer where cname IN (value1,value2,…);
delete from customer where balance BETWEEN 0 AND 50;
select * from customer where phoneno IS NULL;
CS2258 – Database Management Systems Lab 15
Operators usage
 Logical Operator
select * from customer where cname=‘john’ OR
cname=‘joshy’ ;
select * from customer where fname=‘joe’ AND
lname=‘parker’ ;
select * from customer where phoneno IS NOT NULL;
CS2258 – Database Management Systems Lab 16
17
Browse for this material
www.sara-eclass.blogspot.in
CS2258 – Database Management Systems Lab

More Related Content

What's hot

Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
SQL
SQLSQL
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
SQL
SQLSQL
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
rehaniltifat
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
Priyabrat Kar
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptFramgia Vietnam
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
Raveena Thakur
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
Rayhan Chowdhury
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base
Salman Memon
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
Ishucs
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
Syed Zaid Irshad
 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Salman Memon
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
Vikas Gupta
 

What's hot (20)

Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
SQL
SQLSQL
SQL
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
SQL
SQLSQL
SQL
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Sql commands
Sql commandsSql commands
Sql commands
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
 

Similar to SQL Functions and Operators

SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
Andrej Pashchenko
 
sql functions3.pdf about the function of sql
sql functions3.pdf about the function of sqlsql functions3.pdf about the function of sql
sql functions3.pdf about the function of sql
mahakgodwani2555
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10Syed Asrarali
 
sql functions3 (1).pdf
sql functions3 (1).pdfsql functions3 (1).pdf
sql functions3 (1).pdf
Usha570012
 
Mysql Functions with examples CBSE INDIA 11th class NCERT
Mysql Functions with examples CBSE INDIA 11th class NCERTMysql Functions with examples CBSE INDIA 11th class NCERT
Mysql Functions with examples CBSE INDIA 11th class NCERT
Harish Gyanani
 
Sql functions
Sql functionsSql functions
Sql functions
G C Reddy Technologies
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
062MayankSinghal
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
Vineeta Garg
 
Sql FUNCTIONS
Sql FUNCTIONSSql FUNCTIONS
Sql FUNCTIONS
Abrar ali
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
EllenGracePorras
 
Explaining the Postgres Query Optimizer
Explaining the Postgres Query OptimizerExplaining the Postgres Query Optimizer
Explaining the Postgres Query Optimizer
EDB
 
Key functions in_oracle_sql
Key functions in_oracle_sqlKey functions in_oracle_sql
Key functions in_oracle_sqlpgolhar
 
Sql intro
Sql introSql intro
Sql introglubox
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql newSANTOSH RATH
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
RaajTech
 

Similar to SQL Functions and Operators (20)

SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
sql functions3.pdf about the function of sql
sql functions3.pdf about the function of sqlsql functions3.pdf about the function of sql
sql functions3.pdf about the function of sql
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10
 
sql functions3 (1).pdf
sql functions3 (1).pdfsql functions3 (1).pdf
sql functions3 (1).pdf
 
Mysql Functions with examples CBSE INDIA 11th class NCERT
Mysql Functions with examples CBSE INDIA 11th class NCERTMysql Functions with examples CBSE INDIA 11th class NCERT
Mysql Functions with examples CBSE INDIA 11th class NCERT
 
Sql functions
Sql functionsSql functions
Sql functions
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
 
Sql FUNCTIONS
Sql FUNCTIONSSql FUNCTIONS
Sql FUNCTIONS
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Explaining the Postgres Query Optimizer
Explaining the Postgres Query OptimizerExplaining the Postgres Query Optimizer
Explaining the Postgres Query Optimizer
 
Key functions in_oracle_sql
Key functions in_oracle_sqlKey functions in_oracle_sql
Key functions in_oracle_sql
 
Sql intro
Sql introSql intro
Sql intro
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
PPT
PPTPPT
PPT
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Les03 Single Row Function
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

SQL Functions and Operators

  • 1. SQL Functions & Operators CS2258 – Database Management Systems Lab R. Mohan Kumar Assistant Professor / CSE Saranathan College of Engineering
  • 2. SQL Functions  Numeric Functions  Date Functions  Text Functions CS2258 – Database Management Systems Lab Syntax select <function_name> from dual; 2
  • 3. Numeric Functions CS2258 – Database Management Systems Lab FUNCTION NAME DESCRIPTION ABS(x) Absolute value of the number “x” CEIL(x) Integer value that is greater than (or) equal to “x” FLOOR(x) Integer value that is lesser than (or) equal to “x” TRUNC(x,y) Truncate values of “x” upto “y” decimal places. ROUND(x,y) Rounded off value of “x” upto “y” decimal places. 1 of 5 3
  • 4. Numeric Functions CS2258 – Database Management Systems Lab FUNCTION NAME DESCRIPTION MOD(x,y) Returns the result of X % Y (remainder) POWER(x,y) Returns the value of X ^ Y SQRT(x) Returns the square root value of X LOG(x) Returns the Base 10 logarithm of X SIGN(x) 1 if X is POSITIVE ; -1 if X is NEGATIVE ; 0 if X is ZERO 2 of 5 4
  • 5. Numeric Functions CS2258 – Database Management Systems Lab FUNCTION NAME DESCRIPTION SIN(x) Returns the Sine value of X COS(x) Returns the Cosine value of X TAN(x) Returns the Tangent value of X EXP(x) E raised to X exponent LN(x) Returns the Natural Logarithm of X 3 of 5 5
  • 6. Numeric Functions CS2258 – Database Management Systems Lab FUNCTION NAME DESCRIPTION MAX() It selects the MAXIMUM value in the specified column. Syntax: Select MAX(<col_name>) from <table_name>; MIN() It selects the MINIMUM value in the specified column. Syntax: Select MIN(<col_name>) from <table_name>; MEDIAN() It returns the MEDIAN of all values in the given column. Syntax: Select MEDIAN(<col_name>) from <table_name>; 4 of 5 6
  • 7. Numeric Functions CS2258 – Database Management Systems Lab FUNCTION NAME DESCRIPTION AVG() It returns the average of all values in the given column. Syntax: Select AVG(<col_name>) from <table_name>; SUM() It returns the sum of all values in the given column. Syntax: Select SUM(<col_name>) from <table_name>; COUNT() It returns the no. of rows in the given column. Syntax: Select COUNT(<col_name>) from <table_name>; 5 of 5 7
  • 8. Date Functions FUNCTION NAME DESCRIPTION SYSDATE Returns the systems current date. ADD_MONTHS(date,n) Returns a date value after adding in months to the “date”. MONTHS_BETWEEN(x1,x2) Returns the number of months between dates x1 and x2. NEXTDAY(x, weekday) Returns the next date of the “weekday” on or after “x” occurs. LAST_DAY(x) Returns the last date of the particular month. CS2258 – Database Management Systems Lab 1 of 2 8
  • 9. Date Functions FUNCTION NAME DESCRIPTION SysTimeStamp Returns the system date in TIMESTAMP format. To_char(date,format) Returns the date value in given format. Syntax: Select to_char(sysdate,’mm/dd/yy’) from dual; CS2258 – Database Management Systems Lab 2 of 2 9
  • 10. String / Text Functions FUNCTION NAME DESCRIPTION UPPER(x) It converts the string ‘X’ to UPPER case LOWER(x) It converts the string ‘X’ to LOWER case RTRIM(x,y) It returns the string after trimming all occurrence of sub string ‘y’ from right side of the input string ‘X’. LTRIM(x,y) It returns the string after trimming all occurrence of sub string ‘y’ from left side of the input string ‘X’. LENGTH(x) Returns the length of the input string ‘X’ CS2258 – Database Management Systems Lab 1 of 2 10
  • 11. String / Text Functions FUNCTION NAME DESCRIPTION INITCAP(x) It converts the first character of the input string to UPPER case. SUBSTR(x,m,n) Returns the substring of given string starting from position integer ‘m’ and length integer ‘n’. TRANSLATE(x,new,old) It converts the string by substituting the new string in the place of old string. ASCII(c) Returns the ASCII value of the character ‘c’. CHR(number) Returns the character for a ASCII value ‘number’. CS2258 – Database Management Systems Lab 2 of 2 11
  • 12. Operators  Arithmetic Operators + , - , * , /  Comparison Operators = , != , <, <=, >, >= Like, In, Between And , Is Null  Logical Operators OR, AND, NOT CS2258 – Database Management Systems Lab 12
  • 13. Operators usage  Arithmetic Operator select 2 + 3 from dual; select 10 - 5 from dual; select salary + allowance from worker; salary & allowance are the attributes of worker table. update customer set balance = balance + balance * 0.075; CS2258 – Database Management Systems Lab 13
  • 14. Operators usage  Comparison Operator select * from customer where amount = 10000; select * from customer where amount < 500; select * from customer where age > 68; update customer set interest_rate = 0.0925 where age >= 68; delete from customer where balance <= 50; CS2258 – Database Management Systems Lab 14
  • 15. Operators usage  Comparison Operator select * from customer where cname LIKE ‘a%; select * from customer where cname LIKE ‘%er; select * from customer where cname IN (value1,value2,…); delete from customer where balance BETWEEN 0 AND 50; select * from customer where phoneno IS NULL; CS2258 – Database Management Systems Lab 15
  • 16. Operators usage  Logical Operator select * from customer where cname=‘john’ OR cname=‘joshy’ ; select * from customer where fname=‘joe’ AND lname=‘parker’ ; select * from customer where phoneno IS NOT NULL; CS2258 – Database Management Systems Lab 16
  • 17. 17 Browse for this material www.sara-eclass.blogspot.in CS2258 – Database Management Systems Lab