- Display the string ‘bbbStructure Query Language’’ after trimming from left.
SELECT LTRIM(' Structure Query Language');
- Display the string ‘bbStructure Query Languagebbb’ after trimming from right.
SELECT RTRIM('Structure Query Language ');
- Display the length of the string ‘bbString Functionsbbb’ after removing blank spaces from both sides.
SELECT LENGTH(TRIM(' String Functions '));
- Display the reverse of your name.
SELECT REVERSE('YourName'); -- Replace 'YourName' with your actual name.
- Display the string after joining the 3 strings ‘You are ’, ‘learning’ and ‘MYSQL’.
SELECT CONCAT('You are ', 'learning ', 'MYSQL');
- Display the left most 9 characters of the string ‘Structure Query Language’.
SELECT LEFT('Structure Query Language', 9);
- Display the right most 3 characters of the string ‘Structure Query Language’.
SELECT RIGHT('Structure Query Language', 3);
- Display 3 characters from the 6th character of the string ‘Applications’.
SELECT SUBSTRING('Applications', 6, 3);
- Display your name in capital letters and small letters using functions.
SELECT UPPER('YourName'), LOWER('YourName'); -- Replace 'YourName' with your actual name.
-
Display the value 65432.49678:
- After rounding it off to 4 decimal places, 2 decimal places.
SELECT ROUND(65432.49678, 4), ROUND(65432.49678, 2);
- **After rounding it off nearest to 10, nearest to 100, nearest to 1000.**
```sql
SELECT ROUND(65432.49678, -1), ROUND(65432.49678, -2), ROUND(65432.49678, -3);
```
-
Display the square root of the following values:
- 784
SELECT SQRT(784);
- **12.8547**
```sql
SELECT SQRT(12.8547);
```
-
Display the value of 6^3 and 5^5.
SELECT POW(6, 3), POW(5, 5);
-
Display the absolute value of -7 and 13.
SELECT ABS(-7), ABS(13);
-
Display the remainder of the following divisions:
- 78 by 5
SELECT 78 % 5;
- **78 by -5**
```sql
SELECT 78 % -5;
```
- **-78 by 5**
```sql
SELECT -78 % 5;
```
-
Display the day of the month, month, and year portion from the specified date:
- ‘2024-12-25’
SELECT DAY('2024-12-25'), MONTH('2024-12-25'), YEAR('2024-12-25');
- **‘2025-01-01’**
```sql
SELECT DAY('2025-01-01'), MONTH('2025-01-01'), YEAR('2025-01-01');
```
-
Display the name of the month and name of the week of the given date:
- ‘2024-08-10’
SELECT MONTHNAME('2024-08-10'), DAYNAME('2024-08-10');
- **‘2024-11-1’**
```sql
SELECT MONTHNAME('2024-11-1'), DAYNAME('2024-11-1');
```
-
Display the date portion of the given expression ‘2024-08-02 23:45:40’.
SELECT DATE('2024-08-02 23:45:40');
-
Display the time portion of the given expression ‘2024-08-02 23:45:40’.
SELECT TIME('2024-08-02 23:45:40');
-
Display today’s date.
SELECT CURDATE();
-
Display today’s date with time.
SELECT NOW();
Top comments (0)