Vous êtes sur la page 1sur 13

Nama : Rizki Romadhona Nasution

Kelas : TI MSU 3A

NIM : 4817090462

Laporan Group Functions

Vocabulary

1. AVG 2. COUNT 3.STDDEV 4. Group Functions 5. MIN

6. VARIANCE 7. SUM 8. MAX 9. Aggregate

1. AVG : Used with columns that store numeric data to compute the average.

Example:

Query:

Hasil :

2. COUNT : Returns the number of rows

Example:

Query :

Hasil :

3. MAX : Used with columns that store any data type to return the maximum value.

Example :

Query :

Hasil :

4. MIN : Used with columns that store any data type to return the minimum value.
Example:

Query:

Hasil :

5. STDDEV : Standard deviation measures the spread of data.

Example :

Query :

Hasil :

6. SUM : Used with columns that store numeric data to find the total or sum of values.

Example:

Query :

Hasil :

7. VARIANCE : Used with columns that store numeric data t calculate the spread of data around the
mean.

Example:

Query:

Hasil :

2. Query :
Hasil :

3. Query :

Hasil :

4. Query :

Hasil :

5. Query:

Hasil :

6. 1(One)

7.

Dengan query di atas NULL akan di ignored

8. March 30, 1969

9. Query :

10. Query:
Hasil :

11. SUM lebih dari AVG

12. a. False b. True c. False d. False

e. False f. False g. True


Laporan Group Functions

Vocabulary

1. COUNT

2. DISTINCT

3. COUNT(DISTINCT Expression)

1.

2.

3.

4.
5.

- COUNT(*) – all row count is 3, and COUNT(auth_expense_amt) is 1. That’s why above query says 2 are
out of any bound due to auth_expense_amt specified.

- COUNT(auth_expense_amt) is 1 because count skips nulls.

6. 4 and 2

7.

8. a. False b. True c. True d. False

9. a.False b.False c. True d. False


Laporan 9.1

Vocabulary

1. Having

2. Group By

1. a. True b. False c. False d.False e. False

2. a.

b.

c.
d.

3.

4. a. True b.False c.False

5.

6.
9.2 GROUP FUNCTION

Vocabulary
1. Rollup
2. Cube
3. Grouping sets

Try it/ Solve it


1. SELECT manager_id, job_id, SUM(salary) "total salary", GROUPING(manager_id),
GROUPING(job_id)
FROM employees
GROUP BY ROLLUP(manager_id, job_id);

2. SELECT manager_id, job_id, SUM(salary) "total salary", GROUPING(manager_id),


GROUPING(job_id)
FROM employees
GROUP BY CUBE(manager_id, job_id);
3. SELECT department_id, manager_id, job_id, SUM(salary) "total salary",
GROUPING(department_id), GROUPING(manager_id), GROUPING(job_id)
FROM employees
GROUP BY GROUPING SETS((department_id, manager_id, job_id), (manager_id, job_id),
(department_id, manager_id));
9.3

Vocab

 Union
 TO_CHAR(Null) atau TO_DATE(NULL) atau TO_NUMBER(NULL)
 Union All
 Set operators
 Minus
 Intersect

Try And Solve It


1. Union
Union All
Minus
Intersect
2. SELECT employee_id, job_id, hire_date, department_id
FROM employees
UNION
SELECT employee_id, job_id, start_date, department_id
FROM job_history
ORDER BY employee_id, hire_date;

3. SELECT employee_id, job_id, hire_date, department_id


FROM employees
UNION ALL
SELECT employee_id, job_id, start_date, department_id
FROM job_history
ORDER BY employee_id, hire_date;
4. SELECT DISTINCT employee_id
FROM employees
MINUS
SELECT DISTINCT employee_id
FROM job_history;

5. SELECT DISTINCT employee_id


FROM employees
INTERSECT
SELECT DISTINCT employee_id
FROM job_history;

6. SELECT employee_id, job_id, NVL(salary, 0)


FROM employees
UNION
SELECT employee_id, job_id, 0
FROM job_history
ORDER BY employee_id;

Vous aimerez peut-être aussi