Table of Contents
Character/StringFunctions
1. UPPER Function
2. LOWER Function.
3. LTRIM Function.
3
4. RTRIM Function
5. CONCAT Function..
6. LEN Function.
7. REPLACE Function
SUBSTRING Function.
Date & Time Functions
1. GETDATEO unction
2. DATEPARTO Function
4
3. DATEADD) Function
4. DATEDIFF) Function
5. CONVERT) Function.
Numeric Functions
ABS Function.
2 ACOS Function
6
3. ASN Function
6
4. ATAN Function
6
6. BETWEEN Function..
7. MIN Function. 6
7
8. MAX Function
9 SORT Function
10. PIFunction
CEILING Function
12, FLOOR Function.
13. LOG Functíon.
Math Functions.
1. ABS Function
2. POWER Functíon:
3. EXP Function
4. SORT Function.
Character/String Functions
1. UPPER Function:
Query:
SELECTUPPER('pakistan');
Output:
(No column name)
1 PAKISTAN
2. LOWER Function
Query:
SELECTLOWER('PAKISTAN');
Output:
(Nocolumn name)
1 pakistan
3. LTRIM Function:
It Removesleading spaces from a string
Query:
SELECTLTRIM( welcome');
Output:
(Nocolumn name)
1 welcome
4. RTRIM Function:
It removes trailing spaces from a string.
Query:
SELECTRTRIM(*welcome );
Output:
(Nocolumn name)
1 welcome
5. CONCAT Function:
It concatenates the two strings.
Query:
SELECT CONCATEDbUdrin
Output:
(No column name)
1
Jawad Ahmad
6. LEN Function:
It provides the length of a string like number of characters in a string
Query:
SELECT LEN('pakistan');
Output:
(Nocolumn name)
1
7. REPLACE Function:
replaces the all occurrences ofa substringwithin a
It
string.
Query:
SELECT REPLACE(lazy fox', 'dog', 'fox');
Output:
(No column name)
1 lazy fox
8. SUBSTRING Function:
It extracts some characters from a string.
Query:
SELECT SUBSTRING(lazy fox',6,3);
Output:
(No column name)
1 fox
Date & Time Functions
1. GETDATE) Function:
It will return the current date with time.
Query:
SELECT GETDATEO AS currentdatetime;
OUTPUT:
currentdatetime
2024-10-13 15:48:23.390
2. DATEPARTOFunction:
It will return part of current date.
Query:
SELECT DATEPART('year',
GETDATEO) AS currentyear;
Output:
currentyear
1 2024
3. DATEADD) Function:
Itwill display the date and time by adding or subtractingdate and
time interval
Query:
SELECT DATEADD(month, 2,GETDATE)AS DateAdd;
Output:
DateAdd
1 2024-12-13 15:48:23.390
4. DATEDIFF) Function:
It will return the differencebetween two dates.
Query:
SELECT DATEDIFF(month,GETDATE), 2025/11/24) AS DateDIff;
Output:
DateDiff
13
5. CONVERT) Function:
It converts a values into specified datatype.
Query:
SELECT CONVERT(date,GETDATE0) AS TodayDate;
Output:
TodayDate
1 2024-10-13
Numeric Functions
1. ABS Function:
It returns the absolute value of a number.
Query:
SELECT ABS(-2.49) AS absolutenumber;
Output:
TodayDate
1 2024-10-13
2. ACOS Function:
It returns arc cosine of a number. Value must be between -1 to 1.
Query:
SELECT ACOS(-0.95) AS arc cosine;
Output:
arc cosine
1
2.82403222429827
3. ASIN Function:
It returnsarc sine of a number. Value must be between -1to 1.
Query:
SELECT ASIN(0.55) AS ar sine.
Output:
ar_ sine
0.582364237868743
4. ATAN Function:
It returnsarc tangent of a number.
Query:
SELECTATAN(4)AS arc tangent
Output:
arc tangent
1 1.32581766366803
5. ATN2 Function:
It returnsarc tangent oftwo values.
Query:
SELECTATN2(0.4,1.2);
Output:
(No column name)
1 |0.321750554396642
6. BETWEEN Function:
If the values exist between given two expressions, then those will
be come as output.
Query:
SELECT salary FROM users WHERE salary BETWEEN 2000 AND 100000;
Output:
salary
30400.00
2 23000.00
3 23000.00
7. MIN Function:
Minimum value will come asoutput from expression.
Query:
SELECT MIN(age)From users.
Output:
(No column name)
1 12
8. MAX Function:
Maximum values will come as output from the give expression.
Query:
SELECT MAX(age) FROM users.
Output:
(No column name)
1 90
9. SQRT Function:
It returns the square root of a value.
Query:
SELECT SQRT(4);
Output:
(No column name)
2
10. PIFunction:
Pi value come as output.
Query:
SELECT PI);
Output:
(No column name)
3.14159265358979
11. CEILING Function:
Given value will come as output after rounding the decimals which is the next highest value.
Query:
SELECT CEILING(123.25);
Output:
(No column name)
1 124
12. FLOOR Function:
Given value will come as output after rounding the decimals which is less than or equal to the
expression.
Query:
SELECT FLOOR(123.25);
Output:
(No column name)
1
123
13. LOG Function:
Natural logarithm ofthe given expression will come as output.
Query:
Select LOG(1)
Output:
(No column name)
1
Math Functions
1. ABS Function:
It returns absolute value.
Query:
SELECT ABS(-349);
Output:
(No column name)
1 349
2.POWER Function:
It returns the value of a numberraised to the powerofanother number.
Query:
SELECT POWER(4,2);
Output:
(No column name)
1 16
3. EXP Function:
It returns eraised to the power of a specified number.
Query:
SELECT EXP(1);
Output:
(No column name)
1 2.71828182845905
4. SQRT Function:
It returns the square root ofa number.
Query:
SELECT SQRT(64);
Output:
(No column name)
8
3. EXP Function:
Itreturns e raised to the power of a specified number.
Query:
SELECT EXP(1);
Output:
(No column name)
1 2.71828182845905
4. SQRT Function:
Itreturns the square root ofa number.
Query:
SELECT SQRT(64);
Output:
(Nocolumn name)
1 8