We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1cb86b4 commit 98a22a9Copy full SHA for 98a22a9
basics/Commonly Used SQL Functions.md
@@ -9,19 +9,27 @@ SELECT COUNT(*) FROM employees
9
```sql
10
-- Count the number of employees in each department
11
SELECT department, COUNT(*) FROM employees GROUP BY department;
12
-
+```
13
## 2. SUM()
14
Calculates the sum of a set of values.
15
Returns the total sum of a numeric column.
16
17
SELECT SUM(salary) FROM employees
18
```
19
+```sql
20
+-- Calculate the total sum of salaries in each department
21
+SELECT department, SUM(salary) FROM employees GROUP BY department;
22
23
## 3. AVG()
24
Calculates the average value of a set of values.
25
Returns the average value of a numeric column.
26
27
SELECT AVG(salary) FROM employees
28
29
30
+-- Calculate the average salary in each department
31
+SELECT department, AVG(salary) FROM employees GROUP BY department;
32
33
## 4. MAX()
34
Returns the maximum value in a set of values.
35
Finds the highest value in a specified column.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments