Groepsfuncties

Introductie tot Oracle SQL

Hadrien Lacroix

Content Developer

Data aggregeren

Data aggregeren

Introductie tot Oracle SQL

Groepsfuncties

 

 

Groepsfuncties

  • SUM
  • AVG
  • MEDIAN
  • MIN
  • MAX
  • COUNT
Introductie tot Oracle SQL

SUM

SELECT SUM(Milliseconds)
FROM Track
| SUM(Milliseconds) |
|-------------------|
| 1,378,778,040     |
Introductie tot Oracle SQL

AVG, MEDIAN

SELECT AVG(Milliseconds), MEDIAN(Milliseconds)
FROM Track
| AVG(Milliseconds) | MEDIAN(Milliseconds) |
|-------------------|----------------------|
| 393,599.2         | 255,634              |
Introductie tot Oracle SQL

MIN, MAX

SELECT MIN(Milliseconds), MAX(Milliseconds)
FROM Track
| MIN(Milliseconds) | MAX(Milliseconds) |
|-------------------|-------------------|
| 1,071             | 5,286,953         |
Introductie tot Oracle SQL

COUNT

-- Aantal rijen in een tabel
SELECT COUNT(*)
FROM Track
-- Aantal rijen met niet-nullwaarden
SELECT COUNT(Milliseconds)
FROM Track
-- Aantal verschillende niet-nullwaarden
SELECT COUNT(DISTINCT Milliseconds)
FROM Track
| COUNT(*) |
|----------|
| 3503     |
| COUNT(Milliseconds) |
|---------------------|
| 3503                |
| COUNT(DISTINCT Milliseconds) |
|------------------------------|
| 3080                         |
Introductie tot Oracle SQL

Kolom-aliassen

SELECT MIN(Milliseconds)
       SUM(Milliseconds)
FROM Track
| MIN(Milliseconds) | SUM(Milliseconds) |
|-------------------|-------------------|
| 1,071             | 1,378,778,040     |
SELECT MIN(Milliseconds) AS minimum
       SUM(Milliseconds) AS "Totale duur"
FROM Track
| MINIMUM           | Totale duur       |
|-------------------|-------------------|
| 1,071             | 1,378,778,040     |
Introductie tot Oracle SQL

Datatypen

Numerieke data Tekstdata Datedata
AVG x
SUM x
MIN x x x
MAX x x x
COUNT x x x
Introductie tot Oracle SQL

Tekst

CHAR, VARCHAR2

SELECT Name 
FROM Track
| Name           |
|----------------|
| Ashes To Ashes |
| Layla          |
| Everlong       |
| ...            |
Introductie tot Oracle SQL

Numeriek

NUMBER

SELECT Milliseconds 
FROM Track
| Milliseconds |
|--------------|
| 343719       |
| 205688       |
| 267728       |
| ...          |
Introductie tot Oracle SQL

Datum

DATE, DATETIME

SELECT BirthDate 
FROM Employee
| BirthDate  |
|------------|
| 1962-02-18 |
| 1958-12-08 |
| 1973-08-29 |
| ...        |
Introductie tot Oracle SQL

Laten we oefenen!

Introductie tot Oracle SQL

Preparing Video For Download...