Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 98a22a9

Browse files
authored
Update Commonly Used SQL Functions.md
1 parent 1cb86b4 commit 98a22a9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎basics/Commonly Used SQL Functions.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,27 @@ SELECT COUNT(*) FROM employees
99
```sql
1010
-- Count the number of employees in each department
1111
SELECT department, COUNT(*) FROM employees GROUP BY department;
12-
12+
```
1313
## 2. SUM()
1414
Calculates the sum of a set of values.
1515
Returns the total sum of a numeric column.
1616
```sql
1717
SELECT SUM(salary) FROM employees
1818
```
19+
```sql
20+
-- Calculate the total sum of salaries in each department
21+
SELECT department, SUM(salary) FROM employees GROUP BY department;
22+
```
1923
## 3. AVG()
2024
Calculates the average value of a set of values.
2125
Returns the average value of a numeric column.
2226
```sql
2327
SELECT AVG(salary) FROM employees
2428
```
29+
```sql
30+
-- Calculate the average salary in each department
31+
SELECT department, AVG(salary) FROM employees GROUP BY department;
32+
```
2533
## 4. MAX()
2634
Returns the maximum value in a set of values.
2735
Finds the highest value in a specified column.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /