Your marks are 87.456 β but the report card should show 87.5. A shop wants every customer name in CAPITAL letters on the bill. The school office needs to know which month each student joined. π€ You could fix all this by handβ¦ or you could let MySQL do it in one line using functions! This chapter answers the BIG questions: What is a function in SQL? How do math functions round and calculate numbers? How do text functions cut, search, change the case of and trim text? And how do date functions pull out the day, month and year from a date? Let's make MySQL do the hard work! π οΈ
Every function in this chapter is a CBSE syllabus function β there are 24 of them, in three groups: Math (3), Text (14), Date (7). Pay particular attention to ROUND() with negative places, MID()/SUBSTR(), INSTR(), LEFT()/RIGHT(), TRIM(), and MONTHNAME()/DAYNAME(). For every output question, write the characters with their positions (1, 2, 3β¦) above the text first β that's how you never miss a letter!
6.1 π Introduction β What is a Function?
A function is a ready-made command that takes some input (arguments), does a job, and returns a result. You've already used functions in Python β len(), max(), round(). MySQL has its own!
ROUND( 87.456 , 1 ) β 87.5
βββββ ββββββ β ββββ
β β β ββ result (returned value)
β β ββ argument 2 (decimal places)
β ββ argument 1 (the number)
ββ function name
Analogy: A function is like a juicer π β you put in fruit (input), press the button, and get juice (output). You don't need to know how the motor works inside!
6.1.1 Single-Row vs Multiple-Row Functions π
graph TD
F["π οΈ MySQL FUNCTIONS"]
S["1οΈβ£ Single-Row Functions\n(one result for EACH row)"]
M["π Multiple-Row / Aggregate\n(one result for a GROUP of rows)"]
MA["π’ Math\nPOWER, ROUND, MOD"]
TX["π€ Text\nUPPER, MID, INSTR, TRIMβ¦"]
DT["π
Date\nNOW, MONTH, DAYNAMEβ¦"]
AG["SUM, AVG, MAX,\nMIN, COUNT"]
F --> S
F --> M
S --> MA
S --> TX
S --> DT
M --> AG
style S fill:#2196F3,color:#fff
style M fill:#9C27B0,color:#fff
style MA fill:#FF9800,color:#fff
style TX fill:#4CAF50,color:#fff
style DT fill:#F44336,color:#fff
| Single-Row Functions | Multiple-Row (Aggregate) Functions |
|---|---|
| Work on one row at a time | Work on a group of rows together |
| Give one result per row (5 rows in β 5 results out) | Give one result for the whole group |
e.g. UPPER(), ROUND(), YEAR() |
e.g. SUM(), AVG(), COUNT() |
This chapter covers single-row functions. Aggregate functions are covered in the chapter Querying Using SQL.
"Differentiate between single-row and multiple-row functions with one example each." β 2 marks
Answer: A single-row function works on each row separately and returns one result for every row β e.g. UPPER(Name). A multiple-row (aggregate) function works on a group of rows and returns a single result for the whole group β e.g. SUM(Salary).
6.2 ποΈ Our Sample Table β Staff
Most examples in this chapter use this table. Functions can also be tried without any table β SELECT ROUND(87.456, 1); works on its own!
SELECT * FROM Staff;
+-------+-------------+----------+----------+---------+------------+---------+
| EmpID | Name | Dept | Salary | Bonus | JoinDate | City |
+-------+-------------+----------+----------+---------+------------+---------+
| 101 | Ananya Sen | Sales | 45250.75 | 1200.50 | 2021-04-12 | Kolkata |
| 102 | Rahul Verma | Accounts | 52800.40 | 950.00 | 2019-11-25 | Delhi |
| 103 | Priya Nair | Sales | 38900.00 | 1580.25 | 2023-01-03 | Kochi |
| 104 | Arjun Mehta | IT | 67450.60 | 2100.00 | 2020-08-15 | Pune |
| 105 | Sneha Iyer | IT | 59999.99 | 800.75 | 2024-06-30 | Chennai |
+-------+-------------+----------+----------+---------+------------+---------+
6.3 π’ Math Functions
6.3.1 POWER() β‘
POWER(m, n) returns m raised to the power n (mβΏ). POW() is another name for it.
SELECT POWER(2, 3), POWER(5, 2), POWER(2, 10), POWER(4, 0.5);
+-------------+-------------+--------------+---------------+
| POWER(2, 3) | POWER(5, 2) | POWER(2, 10) | POWER(4, 0.5) |
+-------------+-------------+--------------+---------------+
| 8 | 25 | 1024 | 2 |
+-------------+-------------+--------------+---------------+
6.3.2 ROUND() π―
ROUND(n, d) rounds the number n to d decimal places. If d is left out, it rounds to a whole number.
SELECT ROUND(87.456), ROUND(87.456, 1), ROUND(87.456, 2), ROUND(87.5);
+---------------+------------------+------------------+-------------+
| ROUND(87.456) | ROUND(87.456, 1) | ROUND(87.456, 2) | ROUND(87.5) |
+---------------+------------------+------------------+-------------+
| 87 | 87.5 | 87.46 | 88 |
+---------------+------------------+------------------+-------------+
Negative d rounds to the LEFT of the decimal point β to tens, hundreds, thousands:
SELECT ROUND(1234.567, -1), ROUND(1234.567, -2), ROUND(1250, -2), ROUND(1749, -3);
+---------------------+---------------------+-----------------+-----------------+
| ROUND(1234.567, -1) | ROUND(1234.567, -2) | ROUND(1250, -2) | ROUND(1749, -3) |
+---------------------+---------------------+-----------------+-----------------+
| 1230 | 1200 | 1300 | 2000 |
+---------------------+---------------------+-----------------+-----------------+
d = 2 β 87.456 β 87.46 (2 places after the point)
d = 0 β 87.456 β 87 (whole number)
d = -1 β 1234.567 β 1230 (nearest ten)
d = -2 β 1234.567 β 1200 (nearest hundred)
d = -3 β 1749 β 2000 (nearest thousand)
Look at the digit just after the place you are rounding to. 5 or more β round up; 4 or less β keep it. So ROUND(1250, -2) β the tens digit is 5 β 1300.
A positive d keeps digits to the right of the point. A negative d rounds digits to the left of the point and turns them into zeros!
On a table:
SELECT Name, Salary, ROUND(Salary), ROUND(Salary, -3) FROM Staff;
+-------------+----------+---------------+-------------------+
| Name | Salary | ROUND(Salary) | ROUND(Salary, -3) |
+-------------+----------+---------------+-------------------+
| Ananya Sen | 45250.75 | 45251 | 45000 |
| Rahul Verma | 52800.40 | 52800 | 53000 |
| Priya Nair | 38900.00 | 38900 | 39000 |
| Arjun Mehta | 67450.60 | 67451 | 67000 |
| Sneha Iyer | 59999.99 | 60000 | 60000 |
+-------------+----------+---------------+-------------------+
6.3.3 MOD() β
MOD(m, n) returns the remainder when m is divided by n β just like % in Python.
SELECT MOD(17, 5), MOD(20, 4), MOD(7, 10), MOD(-17, 5);
+------------+------------+------------+-------------+
| MOD(17, 5) | MOD(20, 4) | MOD(7, 10) | MOD(-17, 5) |
+------------+------------+------------+-------------+
| 2 | 0 | 7 | -2 |
+------------+------------+------------+-------------+
In MySQL, MOD(-17, 5) gives -2, not 3. (Python's -17 % 5 gives 3 β they are different!)
Using MOD to find even/odd employee IDs:
SELECT EmpID, Name FROM Staff WHERE MOD(EmpID, 2) = 0;
+-------+-------------+
| EmpID | Name |
+-------+-------------+
| 102 | Rahul Verma |
| 104 | Arjun Mehta |
+-------+-------------+
"Write the output: SELECT ROUND(4567.891, -2), POWER(3, 3), MOD(29, 6);" β 2 marks
Answer: 4600, 27, 5
6.4 π€ Text (String) Functions
Text functions work on character data like names and cities. Let's number the letters of a word β MySQL starts counting at 1 (not 0 like Python!):
I N F O R M A T I C S
1 2 3 4 5 6 7 8 9 10 11
Python strings start at index 0, but SQL text functions start at 1. Mixing these up is the #1 mistake in output questions.
6.4.1 UCASE() / UPPER() and LCASE() / LOWER() π
| Function | Does | Example | Result |
|---|---|---|---|
UPPER(s) or UCASE(s) |
Converts to CAPITAL letters | UPPER('India') |
INDIA |
LOWER(s) or LCASE(s) |
Converts to small letters | LCASE('India') |
india |
SELECT UPPER(Name), LCASE(City) FROM Staff WHERE Dept = 'IT';
+-------------+-------------+
| UPPER(Name) | LCASE(City) |
+-------------+-------------+
| ARJUN MEHTA | pune |
| SNEHA IYER | chennai |
+-------------+-------------+
UCASE() = UPPER() and LCASE() = LOWER(). CBSE uses both pairs, so learn both names!
6.4.2 LENGTH() π
LENGTH(s) returns the number of characters in the text β spaces count too!
SELECT Name, LENGTH(Name) FROM Staff;
+-------------+--------------+
| Name | LENGTH(Name) |
+-------------+--------------+
| Ananya Sen | 10 |
| Rahul Verma | 11 |
| Priya Nair | 10 |
| Arjun Mehta | 11 |
| Sneha Iyer | 10 |
+-------------+--------------+
6.4.3 LEFT() and RIGHT() β¬ οΈβ‘οΈ
| Function | Returns | Example | Result |
|---|---|---|---|
LEFT(s, n) |
The first n characters from the left | LEFT('INFORMATICS', 4) |
INFO |
RIGHT(s, n) |
The last n characters from the right | RIGHT('INFORMATICS', 3) |
ICS |
SELECT Name, LEFT(Name, 3), RIGHT(City, 2) FROM Staff;
+-------------+---------------+----------------+
| Name | LEFT(Name, 3) | RIGHT(City, 2) |
+-------------+---------------+----------------+
| Ananya Sen | Ana | ta |
| Rahul Verma | Rah | hi |
| Priya Nair | Pri | hi |
| Arjun Mehta | Arj | ne |
| Sneha Iyer | Sne | ai |
+-------------+---------------+----------------+
Analogy:
LEFT()andRIGHT()are like tearing a strip of paper π β you tear off a piece from the left end or the right end. You always keep the edge!
6.4.4 MID() / SUBSTRING() / SUBSTR() βοΈ
MID(s, start, length) cuts out a piece of text starting at position start, taking length characters. SUBSTRING() and SUBSTR() do exactly the same job.
MID('INFORMATICS', 3, 4)
I N F O R M A T I C S
1 2 3 4 5 6 7 8 9 10 11
ββββββββ
start at 3, take 4 β FORM
SELECT MID('INFORMATICS', 3, 4), SUBSTRING('INFORMATICS', 6, 3), SUBSTR('INFORMATICS', 8);
+--------------------------+--------------------------------+--------------------------+
| MID('INFORMATICS', 3, 4) | SUBSTRING('INFORMATICS', 6, 3) | SUBSTR('INFORMATICS', 8) |
+--------------------------+--------------------------------+--------------------------+
| FORM | MAT | TICS |
+--------------------------+--------------------------------+--------------------------+
- If length is left out, it takes everything till the end (
SUBSTR('INFORMATICS', 8)βTICS). - A negative start counts from the right end:
SELECT SUBSTR('PRACTICES', -3), SUBSTR('PRACTICES', -5, 2);
+-------------------------+----------------------------+
| SUBSTR('PRACTICES', -3) | SUBSTR('PRACTICES', -5, 2) |
+-------------------------+----------------------------+
| CES | TI |
+-------------------------+----------------------------+
On a table β first name of each employee (everything before the space), using INSTR (next section):
SELECT Name, MID(Name, 1, INSTR(Name, ' ') - 1) AS FirstName FROM Staff;
+-------------+-----------+
| Name | FirstName |
+-------------+-----------+
| Ananya Sen | Ananya |
| Rahul Verma | Rahul |
| Priya Nair | Priya |
| Arjun Mehta | Arjun |
| Sneha Iyer | Sneha |
+-------------+-----------+
LEFT takes from the left edge, RIGHT from the right edge, and MID can take a piece from anywhere in the middle β you just tell it where to start and how much to take.
6.4.5 INSTR() π
INSTR(s, sub) returns the position where sub first appears in s. If it is not found, it returns 0.
SELECT INSTR('COMPUTER', 'PUT'), INSTR('BANANA', 'AN'), INSTR('MYSQL', 'Z');
+--------------------------+-----------------------+---------------------+
| INSTR('COMPUTER', 'PUT') | INSTR('BANANA', 'AN') | INSTR('MYSQL', 'Z') |
+--------------------------+-----------------------+---------------------+
| 4 | 2 | 0 |
+--------------------------+-----------------------+---------------------+
SELECT Name, INSTR(Name, 'a') FROM Staff;
+-------------+------------------+
| Name | INSTR(Name, 'a') |
+-------------+------------------+
| Ananya Sen | 1 |
| Rahul Verma | 2 |
| Priya Nair | 5 |
| Arjun Mehta | 1 |
| Sneha Iyer | 5 |
+-------------+------------------+
INSTR(Name, 'a') also finds a capital A β that's why "Ananya Sen" gives 1. And INSTR returns only the first match, not all of them.
6.4.6 LTRIM(), RTRIM() and TRIM() π§Ή
These remove extra spaces that users often type by mistake.
| Function | Removes spaces from | Example (' Hi ') |
Result |
|---|---|---|---|
LTRIM(s) |
the left (leading) | LTRIM(' Hi ') |
'Hi ' |
RTRIM(s) |
the right (trailing) | RTRIM(' Hi ') |
' Hi' |
TRIM(s) |
both sides | TRIM(' Hi ') |
'Hi' |
Spaces are invisible, so let's measure them with LENGTH():
SELECT LENGTH(' Hello '), LENGTH(LTRIM(' Hello ')), LENGTH(RTRIM(' Hello ')), LENGTH(TRIM(' Hello '));
+-----------------------+------------------------------+------------------------------+-----------------------------+
| LENGTH(' Hello ') | LENGTH(LTRIM(' Hello ')) | LENGTH(RTRIM(' Hello ')) | LENGTH(TRIM(' Hello ')) |
+-----------------------+------------------------------+------------------------------+-----------------------------+
| 11 | 8 | 8 | 5 |
+-----------------------+------------------------------+------------------------------+-----------------------------+
TRIM(' Ravi Kumar ') gives 'Ravi Kumar' β the two spaces between the words stay!
Analogy: TRIM is like a tailor trimming loose threads βοΈ from both ends of a cloth β the design in the middle is never touched.
"Write the output: SELECT LEFT('CBSE EXAM', 4), MID('CBSE EXAM', 6, 2), INSTR('CBSE EXAM', 'E'), LENGTH(TRIM(' CBSE '));" β 2 marks
Answer: CBSE, EX, 4, 4
6.5 π Date Functions
Dates in MySQL are written as 'YYYY-MM-DD'. Date functions let us pull out parts of a date.
6.5.1 NOW() and DATE() π
| Function | Returns |
|---|---|
NOW() |
The current date and time (from the computer's clock) |
DATE(x) |
Only the date part of a date-time value |
SELECT NOW(), DATE(NOW());
+---------------------+-------------+
| NOW() | DATE(NOW()) |
+---------------------+-------------+
| 2026-10-05 05:17:13 | 2026-10-05 |
+---------------------+-------------+
(Your output will show the date and time at which you run the query.)
SELECT DATE('2026-10-05 14:30:00');
+-----------------------------+
| DATE('2026-10-05 14:30:00') |
+-----------------------------+
| 2026-10-05 |
+-----------------------------+
6.5.2 YEAR(), MONTH(), DAY() ποΈ
'2021-04-12'
ββββ ββ ββ
β β ββ DAY() β 12
β ββ MONTH() β 4
ββ YEAR() β 2021
SELECT Name, JoinDate, YEAR(JoinDate), MONTH(JoinDate), DAY(JoinDate) FROM Staff;
+-------------+------------+----------------+-----------------+---------------+
| Name | JoinDate | YEAR(JoinDate) | MONTH(JoinDate) | DAY(JoinDate) |
+-------------+------------+----------------+-----------------+---------------+
| Ananya Sen | 2021-04-12 | 2021 | 4 | 12 |
| Rahul Verma | 2019-11-25 | 2019 | 11 | 25 |
| Priya Nair | 2023-01-03 | 2023 | 1 | 3 |
| Arjun Mehta | 2020-08-15 | 2020 | 8 | 15 |
| Sneha Iyer | 2024-06-30 | 2024 | 6 | 30 |
+-------------+------------+----------------+-----------------+---------------+
6.5.3 MONTHNAME() and DAYNAME() π
| Function | Returns | Example | Result |
|---|---|---|---|
MONTHNAME(d) |
Name of the month | MONTHNAME('2021-04-12') |
April |
DAYNAME(d) |
Name of the weekday | DAYNAME('2021-04-12') |
Monday |
SELECT Name, MONTHNAME(JoinDate), DAYNAME(JoinDate) FROM Staff;
+-------------+---------------------+-------------------+
| Name | MONTHNAME(JoinDate) | DAYNAME(JoinDate) |
+-------------+---------------------+-------------------+
| Ananya Sen | April | Monday |
| Rahul Verma | November | Monday |
| Priya Nair | January | Tuesday |
| Arjun Mehta | August | Saturday |
| Sneha Iyer | June | Sunday |
+-------------+---------------------+-------------------+
MONTH() and DAY() give numbers (4, 12). Add NAME β MONTHNAME(), DAYNAME() β and you get words (April, Monday)!
DAY('2021-04-12') gives 12 (the date of the month). For the weekday, use DAYNAME() β Monday.
Date functions in WHERE β staff who joined before 2021:
SELECT Name, JoinDate FROM Staff WHERE YEAR(JoinDate) < 2021;
+-------------+------------+
| Name | JoinDate |
+-------------+------------+
| Rahul Verma | 2019-11-25 |
| Arjun Mehta | 2020-08-15 |
+-------------+------------+
"Write a query to display the name and the month name of joining of all staff who joined in the month of January." β 1 mark Answer:
SELECT Name, MONTHNAME(JoinDate) FROM Staff WHERE MONTH(JoinDate) = 1;6.6 π§© Using Functions Together
Functions can be nested β the output of one becomes the input of another. MySQL works from the inside out.
SELECT UPPER(LEFT(City, 3)) AS Code, ROUND(Salary / 12) AS MonthlyPay FROM Staff WHERE Dept = 'Sales';
+------+------------+
| Code | MonthlyPay |
+------+------------+
| KOL | 3771 |
| KOC | 3242 |
+------+------------+
UPPER( LEFT('Kolkata', 3) )
βββββ 'Kol' βββββ β inner function first
UPPER('Kol') β 'KOL' β then the outer function
π§Ύ All 24 Syllabus Functions at a Glance
| Group | Function | Example | Result |
|---|---|---|---|
| Math | POWER(m, n) |
POWER(2, 5) |
32 |
| Math | ROUND(n, d) |
ROUND(56.789, 1) |
56.8 |
| Math | MOD(m, n) |
MOD(23, 4) |
3 |
| Text | UCASE() / UPPER() |
UPPER('cbse') |
CBSE |
| Text | LCASE() / LOWER() |
LOWER('CBSE') |
cbse |
| Text | MID() / SUBSTRING() / SUBSTR() |
MID('PYTHON', 2, 3) |
YTH |
| Text | LENGTH() |
LENGTH('MySQL') |
5 |
| Text | LEFT() |
LEFT('PYTHON', 2) |
PY |
| Text | RIGHT() |
RIGHT('PYTHON', 2) |
ON |
| Text | INSTR() |
INSTR('PYTHON', 'TH') |
3 |
| Text | LTRIM() / RTRIM() / TRIM() |
TRIM(' ab ') |
ab |
| Date | NOW() |
NOW() |
current date and time |
| Date | DATE() |
DATE('2026-10-05 09:15:00') |
2026-10-05 |
| Date | MONTH() |
MONTH('2026-10-05') |
10 |
| Date | MONTHNAME() |
MONTHNAME('2026-10-05') |
October |
| Date | YEAR() |
YEAR('2026-10-05') |
2026 |
| Date | DAY() |
DAY('2026-10-05') |
5 |
| Date | DAYNAME() |
DAYNAME('2026-10-05') |
Monday |
β οΈ Common Errors and Misconceptions
| Mistake | What's Wrong | Correct Understanding |
|---|---|---|
| Counting text positions from 0 | SQL starts at 1 | MID('ABC', 1, 1) is A |
ROUND(1234.5, -2) = 1234.50 |
Negative d rounds to the left | It gives 1200 |
MOD(-17, 5) = 3 |
MySQL keeps the sign of the first number | It gives -2 |
DAY() gives the weekday |
DAY() gives the date number | Use DAYNAME() for Monday, Tuesday⦠|
MONTH('2026-10-05') = October |
MONTH() gives a number | 10; use MONTHNAME() for October |
INSTR() returns -1 when not found |
MySQL returns 0 | Not found β 0 |
| "TRIM removes all spaces" | Only leading and trailing | Spaces between words stay |
| "LENGTH ignores spaces" | Spaces are characters | LENGTH('a b') = 3 |
LEFT('PYTHON') |
LEFT needs the number of characters | LEFT('PYTHON', 2) |
Text without quotes: UPPER(india) |
It is treated as a column name | UPPER('india') |
- Function β takes arguments, returns a value; single-row (one result per row) vs aggregate (one result per group)
- POWER(m, n) β mβΏ; ROUND(n, d) β d places (negative d β tens/hundreds); MOD(m, n) β remainder
- UPPER/UCASE, LOWER/LCASE β change case
- LENGTH(s) β number of characters (spaces count)
- LEFT(s, n), RIGHT(s, n) β n characters from the left / right
- MID / SUBSTRING / SUBSTR(s, start, len) β piece from position start; no len β till the end; negative start β from the right
- INSTR(s, sub) β first position of sub; 0 if not found
- LTRIM / RTRIM / TRIM β remove leading / trailing / both-side spaces (not middle)
- NOW() β current date-time; DATE() β date part
- YEAR(), MONTH(), DAY() β numbers; MONTHNAME(), DAYNAME() β words
- Text positions in SQL start at 1; text and dates go in single quotes
π― Sample Board Exam Questions
Q1: Very Short Answer [1 mark each]
a) What will SELECT INSTR('INFORMATION', 'FOR'); return?
Answer: 3
b) Name the function that returns the weekday name of a date.
Answer: DAYNAME()
c) What is the output of SELECT ROUND(73.586, 2);?
Answer: 73.59
d) Write another name for the UCASE() function.
Answer: UPPER()
e) What does LENGTH(TRIM(' SQL ')) return?
Answer: 3
Q2: Output Based [2 marks]
SELECT MID('CYBER SAFETY', 7, 3), RIGHT('CYBER SAFETY', 4), POWER(2, 4), MOD(25, 7);
Answer:
+---------------------------+--------------------------+-------------+------------+
| MID('CYBER SAFETY', 7, 3) | RIGHT('CYBER SAFETY', 4) | POWER(2, 4) | MOD(25, 7) |
+---------------------------+--------------------------+-------------+------------+
| SAF | FETY | 16 | 4 |
+---------------------------+--------------------------+-------------+------------+
Q3: Output Based [3 marks]
Using the Staff table, write the output of:
SELECT LCASE(Dept), MONTHNAME(JoinDate), ROUND(Bonus, -2) FROM Staff WHERE Salary > 50000;
Answer:
+-------------+---------------------+------------------+
| LCASE(Dept) | MONTHNAME(JoinDate) | ROUND(Bonus, -2) |
+-------------+---------------------+------------------+
| accounts | November | 1000 |
| it | August | 2100 |
| it | June | 800 |
+-------------+---------------------+------------------+
Q4: Write Queries [1 mark each]
a) Display the names of all staff in capital letters.
SELECT UPPER(Name) FROM Staff;
b) Display the first 4 letters of each city.
SELECT LEFT(City, 4) FROM Staff;
c) Display the name and the year of joining of each staff member.
SELECT Name, YEAR(JoinDate) FROM Staff;
d) Display the salary of each staff member rounded to the nearest hundred.
SELECT Name, ROUND(Salary, -2) FROM Staff;
e) Display the names of staff whose name has more than 10 characters.
SELECT Name FROM Staff WHERE LENGTH(Name) > 10;
Q5: Short Answer [2 marks]
Differentiate between ROUND(n, 1) and ROUND(n, -1) using n = 256.78.
Answer: ROUND(256.78, 1) rounds to one decimal place and gives 256.8. ROUND(256.78, -1) rounds to the nearest ten (left of the decimal point) and gives 260.
βοΈ Practice Problems
- Write the output:
SELECT POWER(3, 4), ROUND(9876.54, -3), MOD(50, 8); - Write the output:
SELECT LEFT('NETWORK', 3), RIGHT('NETWORK', 4), MID('NETWORK', 2, 3); - What does
INSTR('PROGRAMMING', 'M')return? What aboutINSTR('PROGRAMMING', 'X')? - Write a query to display the last 3 characters of each staff member's name.
- Write a query to display the names of staff who joined on a Monday.
- Write a query to display each staff member's name and their total pay (Salary + Bonus) rounded to a whole number.
- Write the output:
SELECT LENGTH(' CS & IP '), LENGTH(LTRIM(' CS & IP ')); - Write a query to display the names of staff who joined in the month of August.
- What is the difference between
DAY()andDAYNAME()? Give an example. - Write a query to display the position of the first space in each staff member's name.
- Write the output of
SELECT UCASE(MID('database', 1, 4)); - Why does
SELECT UPPER(Name) FROM Staff;not change the names stored in the table?