Db lab assignment
Db lab assignment
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.
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:
2. LOWER Function
Query:
SELECTLOWER('PAKISTAN');
Output:
(Nocolumn name)
1 pakistan
3. LTRIM Function:
Query:
SELECTLTRIM( welcome');
Output:
(Nocolumn name)
1 welcome
4. RTRIM Function:
Query:
SELECTRTRIM(*welcome );
Output:
(Nocolumn name)
1 welcome
5. CONCAT Function:
Query:
SELECT CONCATEDbUdrin
Output:
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:
8. SUBSTRING Function:
It extracts some characters from a string.
Query:
SELECT SUBSTRING(lazy fox',6,3);
Output:
Query:
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:
Output:
DateAdd
1 2024-12-13 15:48:23.390
4. DATEDIFF) Function:
It will return the differencebetween two dates.
Query:
Output:
DateDiff
13
5. CONVERT) Function:
It converts a values into specified datatype.
Query:
Output:
TodayDate
1 2024-10-13
Numeric Functions
1. ABS Function:
It returns the absolute value of a number.
Query:
Output:
TodayDate
1 2024-10-13
2. ACOS Function:
It returns arc cosine of a number. Value must be between -1 to 1.
Query:
Output:
arc cosine
1
2.82403222429827
3. ASIN Function:
It returnsarc sine of a number. Value must be between -1to 1.
Query:
Output:
ar_ sine
0.582364237868743
4. ATAN Function:
It returnsarc tangent of a number.
Query:
Output:
arc tangent
1 1.32581766366803
5. ATN2 Function:
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:
Output:
8. MAX Function:
Maximum values will come as output from the give expression.
Query:
Output:
9. SQRT Function:
It returns the square root of a value.
Query:
SELECT SQRT(4);
Output:
10. PIFunction:
Pi value come as output.
Query:
SELECT PI);
Output:
Given value will come as output after rounding the decimals which is the next highest value.
Query:
SELECT CEILING(123.25);
Output:
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
Query:
Select LOG(1)
Output:
Math Functions
1. ABS Function:
Query:
SELECT ABS(-349);
Output:
2.POWER Function:
It returns the value of a numberraised to the powerofanother number.
Query:
SELECT POWER(4,2);
Output:
Query:
SELECT EXP(1);
Output:
4. SQRT Function:
It returns the square root ofa number.
Query:
SELECT SQRT(64);
Output:
Query:
SELECT EXP(1);
Output:
4. SQRT Function:
Itreturns the square root ofa number.
Query:
SELECT SQRT(64);
Output:
(Nocolumn name)
1 8