@@ -36,42 +36,70 @@ Finds the highest value in a specified column.
3636``` sql
3737SELECT MAX (salary) FROM employees
3838```
39+ ``` sql
40+ -- Find the highest salary in each department
41+ SELECT department, MAX (salary) FROM employees GROUP BY department;
42+ ```
3943## 5. MIN()
4044Returns the minimum value in a set of values.
4145Finds the lowest value in a specified column.
4246``` sql
4347SELECT MIN (salary) FROM employees
4448```
49+ ``` sql
50+ -- Find the lowest salary in each department
51+ SELECT department, MIN (salary) FROM employees GROUP BY department;
52+ ```
4553## 6. CONCAT()
4654Concatenates two or more strings together.
4755Joins multiple strings into a single string.
4856``` sql
4957SELECT CONCAT(first_name, ' ' , last_name) AS full_name FROM employees
5058```
59+ ``` sql
60+ -- Concatenate first name and last name with a comma separator
61+ SELECT CONCAT(first_name, ' , ' , last_name) AS full_name FROM employees;
62+ ```
5163## 7. SUBSTRING()
5264Extracts a substring from a string.
5365Returns a specified part of a string.
5466``` sql
5567SELECT SUBSTRING (phone_number, 1 , 3 ) AS area_code FROM employees
5668```
69+ ``` sql
70+ -- Extract the first 5 characters of each employee's first name
71+ SELECT SUBSTRING (first_name, 1 , 5 ) AS short_name FROM employees;
72+ ```
5773## 8. LOWER()
5874Converts a string to lowercase.
5975Returns the string with all characters in lowercase.
6076``` sql
6177SELECT LOWER (first_name) FROM employees
6278```
79+ ``` sql
80+ -- Convert email addresses to lowercase
81+ SELECT LOWER (email) FROM employees;
82+ ```
6383## 9. UPPER()
6484Converts a string to uppercase.
6585Returns the string with all characters in uppercase.
6686``` sql
6787SELECT UPPER (last_name) FROM employees
6888```
89+ ``` sql
90+ -- Convert department names to uppercase
91+ SELECT UPPER (department) FROM employees;
92+ ```
6993## 10. LENGTH()
7094Returns the length of a string.
7195Calculates the number of characters in a string.
7296``` sql
7397SELECT LENGTH(first_name) AS name_length FROM employees
7498```
99+ ``` sql
100+ -- Calculate the length of each employee's last name
101+ SELECT LENGTH(last_name) AS last_name_length FROM employees;
102+ ```
75103## 11. ROUND()
76104Rounds a numeric value to a specified number of decimal places.
77105Returns the rounded value of a number.
0 commit comments