SlideShare a Scribd company logo
1 of 12
Guest lecture on SQL Functions
presented by:
Aamir Maqsood(M tech. CSE)
Introduction to SQL functions
- What are SQL functions?
- Why are SQL functions important?
- Common types of SQL functions
- Scalar functions
- Aggregate functions
- String functions
- Date and time functions
- Mathematical functions
- Overview of popular SQL functions
- Examples of SQL functions in action
Conclusion and recap of key points
SQL And SQL Functions
 SQL, which stands for Structured Query Language, is a domain-specific
language used for managing and manipulating data in relational database
management systems (RDBMS).
 It is a standard language for communicating with and querying databases. SQL
allows you to perform various operations on data, including retrieving,
updating, inserting, and deleting records, as well as defining and modifying the
structure of a database.
 SQL functions are predefined or user-defined procedures that can be used
within SQL statements to perform various operations on data.
Common Types of SQL Functions
 Scalar Functions:
 Scalar functions are used to perform calculations on a single value and return a
single result. Some examples of scalar functions in SQL include −
 LENGTH() - Returns the number of characters in a string
 UPPER() - Converts a string to uppercase
 LOWER() - Converts a string to lowercase
 CONCAT() - Concatenates two or more strings together
 ROUND() - Rounds a number to a specified number of decimal places
Contd…
 Aggregate Functions:
 Aggregate functions are used to perform calculations on a set of values and
return a single result. Some of the most commonly used aggregate functions in
SQL include −
 COUNT() - Returns the number of rows in a table or the number of non-
NULL values in a column
SELECT COUNT(*) FROM orders;
 SUM() - Returns the sum of all non-NULL values in a column
 AVG() - Returns the average of all non-NULL values in a column
 MIN() - Returns the minimum value in a column
 MAX() - Returns the maximum value in a column
Contd..
 Date and Time Functions
 SQL also provides a number of functions for working with date and time
values. Some examples of date and time functions in SQL include −
 NOW() - Returns the current date and time
 CURRENT_DATE() - Returns the current date
 CURRENT_TIME() - Returns the current time
 YEAR() - Returns the year of a date
 MONTH() - Returns the month of a date
 DAY() - Returns the day of a date
Contd…
 String Functions:
 SQL also provides a number of string manipulation function. Some examples
of string functions in SQL include −
 LTRIM() - Removes the leading whitespace of the string
 RTRIM() - Removes the trailing whitespace of the string
 TRIM() - Removes both leading and trailing whitespace of the string
 SUBSTRING() - Extracts a specific portion of a string
 REPLACE() - Replaces all occurrences of a specified string with another
string
Contd…
 Conditional Functions
 SQL also provides a number of functions that perform different actions based
on certain conditions. Some examples of conditional functions in SQL include
−
 CASE - evaluates a list of conditions and returns a result for the first condition
that is met
 IF - return a specified value if the condition is met, otherwise return another
specified value
 COALESCE - return the first non-null expression among multiple
expressions.
Contd…
 Logical Functions
 SQL provides a set of logical functions that return a Boolean value, which can
be either true or false. Some examples of logical functions in SQL include −
 AND - Returns true if both the conditions are true
 OR - Returns true if at least one of the conditions is true
 NOT - Negates a boolean value
Contd…
 Conversion Functions
 SQL provides a number of functions that can be used to convert data from one
type to another. Some examples of conversion functions in SQL include −
 CAST() - Converts a value from one data type to another
 CONVERT() - Converts a value from one data type to another (This function
is specific for some database vendors like SQL Server)
 TO_DATE() - Converts a string to a date value
 TO_TIME() - Converts a string to a time value
 TO_TIMESTAMP() - Converts a string to a timestamp value
Contd…
 Window Functions
 SQL provides a set of functions that can be used to perform calculations across
a set of rows that are related to the current row. These functions are known as
window functions. Some examples of window functions in SQL include −
 RANK() - Assigns a unique rank to each row within a result set, based on the
values in one or more columns
 DENSE_RANK() - Assigns a unique rank to each row within a result set,
based on the values in one or more columns, but does not leave gaps in the
ranking sequence when there are ties
 ROW_NUMBER() - Assigns a unique number to each row within a result set,
based on the order specified in the ORDER BY clause of the function
Thankyou!

More Related Content

Similar to 12th.pptx (20)

Mysql1
Mysql1Mysql1
Mysql1
 
Sql functions
Sql functionsSql functions
Sql functions
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Les03 Single Row Function
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Function and types
Function  and typesFunction  and types
Function and types
 
xii-ip-support-material.pdf
xii-ip-support-material.pdfxii-ip-support-material.pdf
xii-ip-support-material.pdf
 
Sql functions
Sql functionsSql functions
Sql functions
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
ADVANCED MODELLING.pptx
ADVANCED MODELLING.pptxADVANCED MODELLING.pptx
ADVANCED MODELLING.pptx
 
SQL Query
SQL QuerySQL Query
SQL Query
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Sqlapi0.1
Sqlapi0.1Sqlapi0.1
Sqlapi0.1
 
Intro to tsql unit 10
Intro to tsql   unit 10Intro to tsql   unit 10
Intro to tsql unit 10
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
 
SQL Notes
SQL NotesSQL Notes
SQL Notes
 
Tableau functions
Tableau   functionsTableau   functions
Tableau functions
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07
 
Module02
Module02Module02
Module02
 

More from AamirMaqsood8

DEEPLEARNING recurrent neural networs.pdf
DEEPLEARNING recurrent neural networs.pdfDEEPLEARNING recurrent neural networs.pdf
DEEPLEARNING recurrent neural networs.pdfAamirMaqsood8
 
Activation Function.pptx
Activation Function.pptxActivation Function.pptx
Activation Function.pptxAamirMaqsood8
 
Research Methodology3_Measurement.pptx
Research Methodology3_Measurement.pptxResearch Methodology3_Measurement.pptx
Research Methodology3_Measurement.pptxAamirMaqsood8
 
Research Methodology2.pptx
Research Methodology2.pptxResearch Methodology2.pptx
Research Methodology2.pptxAamirMaqsood8
 
Research Methodology_Intro.pptx
Research Methodology_Intro.pptxResearch Methodology_Intro.pptx
Research Methodology_Intro.pptxAamirMaqsood8
 
sdnppt-140325015756-phpapp01.pptx
sdnppt-140325015756-phpapp01.pptxsdnppt-140325015756-phpapp01.pptx
sdnppt-140325015756-phpapp01.pptxAamirMaqsood8
 
Computer-Networks.pptx
Computer-Networks.pptxComputer-Networks.pptx
Computer-Networks.pptxAamirMaqsood8
 
asrar ppt^.^.^^.pptx
asrar ppt^.^.^^.pptxasrar ppt^.^.^^.pptx
asrar ppt^.^.^^.pptxAamirMaqsood8
 
stacks and queues.pptx
stacks and queues.pptxstacks and queues.pptx
stacks and queues.pptxAamirMaqsood8
 
Class10_OO_Testing.pdf
Class10_OO_Testing.pdfClass10_OO_Testing.pdf
Class10_OO_Testing.pdfAamirMaqsood8
 

More from AamirMaqsood8 (20)

DEEPLEARNING recurrent neural networs.pdf
DEEPLEARNING recurrent neural networs.pdfDEEPLEARNING recurrent neural networs.pdf
DEEPLEARNING recurrent neural networs.pdf
 
WIRELESSPPT.pptx
WIRELESSPPT.pptxWIRELESSPPT.pptx
WIRELESSPPT.pptx
 
Activation Function.pptx
Activation Function.pptxActivation Function.pptx
Activation Function.pptx
 
Research Methodology3_Measurement.pptx
Research Methodology3_Measurement.pptxResearch Methodology3_Measurement.pptx
Research Methodology3_Measurement.pptx
 
iram,sadaf.pptx
iram,sadaf.pptxiram,sadaf.pptx
iram,sadaf.pptx
 
Research Methodology2.pptx
Research Methodology2.pptxResearch Methodology2.pptx
Research Methodology2.pptx
 
LOSTANDFOUND.pptx
LOSTANDFOUND.pptxLOSTANDFOUND.pptx
LOSTANDFOUND.pptx
 
BARRIER.pptx
BARRIER.pptxBARRIER.pptx
BARRIER.pptx
 
HPA.pptx
HPA.pptxHPA.pptx
HPA.pptx
 
Unit2-RM.pptx
Unit2-RM.pptxUnit2-RM.pptx
Unit2-RM.pptx
 
2202cukmr01.pptx
2202cukmr01.pptx2202cukmr01.pptx
2202cukmr01.pptx
 
Research Methodology_Intro.pptx
Research Methodology_Intro.pptxResearch Methodology_Intro.pptx
Research Methodology_Intro.pptx
 
sdnppt-140325015756-phpapp01.pptx
sdnppt-140325015756-phpapp01.pptxsdnppt-140325015756-phpapp01.pptx
sdnppt-140325015756-phpapp01.pptx
 
Computer-Networks.pptx
Computer-Networks.pptxComputer-Networks.pptx
Computer-Networks.pptx
 
asrar ppt^.^.^^.pptx
asrar ppt^.^.^^.pptxasrar ppt^.^.^^.pptx
asrar ppt^.^.^^.pptx
 
asrarsjsjsj.pptx
asrarsjsjsj.pptxasrarsjsjsj.pptx
asrarsjsjsj.pptx
 
videographyppt.pptx
videographyppt.pptxvideographyppt.pptx
videographyppt.pptx
 
stacks and queues.pptx
stacks and queues.pptxstacks and queues.pptx
stacks and queues.pptx
 
Class10_OO_Testing.pdf
Class10_OO_Testing.pdfClass10_OO_Testing.pdf
Class10_OO_Testing.pdf
 
9TH CLASS.pptx
9TH CLASS.pptx9TH CLASS.pptx
9TH CLASS.pptx
 

Recently uploaded

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 

Recently uploaded (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 

12th.pptx

  • 1. Guest lecture on SQL Functions presented by: Aamir Maqsood(M tech. CSE)
  • 2. Introduction to SQL functions - What are SQL functions? - Why are SQL functions important? - Common types of SQL functions - Scalar functions - Aggregate functions - String functions - Date and time functions - Mathematical functions - Overview of popular SQL functions - Examples of SQL functions in action Conclusion and recap of key points
  • 3. SQL And SQL Functions  SQL, which stands for Structured Query Language, is a domain-specific language used for managing and manipulating data in relational database management systems (RDBMS).  It is a standard language for communicating with and querying databases. SQL allows you to perform various operations on data, including retrieving, updating, inserting, and deleting records, as well as defining and modifying the structure of a database.  SQL functions are predefined or user-defined procedures that can be used within SQL statements to perform various operations on data.
  • 4. Common Types of SQL Functions  Scalar Functions:  Scalar functions are used to perform calculations on a single value and return a single result. Some examples of scalar functions in SQL include −  LENGTH() - Returns the number of characters in a string  UPPER() - Converts a string to uppercase  LOWER() - Converts a string to lowercase  CONCAT() - Concatenates two or more strings together  ROUND() - Rounds a number to a specified number of decimal places
  • 5. Contd…  Aggregate Functions:  Aggregate functions are used to perform calculations on a set of values and return a single result. Some of the most commonly used aggregate functions in SQL include −  COUNT() - Returns the number of rows in a table or the number of non- NULL values in a column SELECT COUNT(*) FROM orders;  SUM() - Returns the sum of all non-NULL values in a column  AVG() - Returns the average of all non-NULL values in a column  MIN() - Returns the minimum value in a column  MAX() - Returns the maximum value in a column
  • 6. Contd..  Date and Time Functions  SQL also provides a number of functions for working with date and time values. Some examples of date and time functions in SQL include −  NOW() - Returns the current date and time  CURRENT_DATE() - Returns the current date  CURRENT_TIME() - Returns the current time  YEAR() - Returns the year of a date  MONTH() - Returns the month of a date  DAY() - Returns the day of a date
  • 7. Contd…  String Functions:  SQL also provides a number of string manipulation function. Some examples of string functions in SQL include −  LTRIM() - Removes the leading whitespace of the string  RTRIM() - Removes the trailing whitespace of the string  TRIM() - Removes both leading and trailing whitespace of the string  SUBSTRING() - Extracts a specific portion of a string  REPLACE() - Replaces all occurrences of a specified string with another string
  • 8. Contd…  Conditional Functions  SQL also provides a number of functions that perform different actions based on certain conditions. Some examples of conditional functions in SQL include −  CASE - evaluates a list of conditions and returns a result for the first condition that is met  IF - return a specified value if the condition is met, otherwise return another specified value  COALESCE - return the first non-null expression among multiple expressions.
  • 9. Contd…  Logical Functions  SQL provides a set of logical functions that return a Boolean value, which can be either true or false. Some examples of logical functions in SQL include −  AND - Returns true if both the conditions are true  OR - Returns true if at least one of the conditions is true  NOT - Negates a boolean value
  • 10. Contd…  Conversion Functions  SQL provides a number of functions that can be used to convert data from one type to another. Some examples of conversion functions in SQL include −  CAST() - Converts a value from one data type to another  CONVERT() - Converts a value from one data type to another (This function is specific for some database vendors like SQL Server)  TO_DATE() - Converts a string to a date value  TO_TIME() - Converts a string to a time value  TO_TIMESTAMP() - Converts a string to a timestamp value
  • 11. Contd…  Window Functions  SQL provides a set of functions that can be used to perform calculations across a set of rows that are related to the current row. These functions are known as window functions. Some examples of window functions in SQL include −  RANK() - Assigns a unique rank to each row within a result set, based on the values in one or more columns  DENSE_RANK() - Assigns a unique rank to each row within a result set, based on the values in one or more columns, but does not leave gaps in the ranking sequence when there are ties  ROW_NUMBER() - Assigns a unique number to each row within a result set, based on the order specified in the ORDER BY clause of the function