Analyse exploratoire des données en SQL
Christina Maimone
Data Scientist
| Nom | Taille de stockage | Description | Plage |
|---|---|---|---|
integer ou int ou int4 |
4 octets | choix habituel | -2147483648 à +2147483647 |
| Nom | Taille de stockage | Description | Plage |
|---|---|---|---|
integer ou int ou int4 |
4 octets | choix habituel | -2147483648 à +2147483647 |
smallint ou int2 |
2 octets | petite plage | -32768 à +32767 |
bigint ou int8 |
8 octets | grande plage | -9223372036854775808 à +9223372036854775807 |
| Nom | Taille de stockage | Description | Plage |
|---|---|---|---|
integer ou int ou int4 |
4 octets | choix habituel | -2147483648 à +2147483647 |
smallint ou int2 |
2 octets | petite plage | -32768 à +32767 |
bigint ou int8 |
8 octets | grande plage | -9223372036854775808 à +9223372036854775807 |
serial |
4 octets | incrément automatique | 1 à 2147483647 |
smallserial |
2 octets | petit incrément automatique | 1 à 32767 |
bigserial |
8 octets | grand incrément automatique | 1 à 9223372036854775807 |
| Nom | Capacité de stockage | Description | Plage |
|---|---|---|---|
decimal ou numeric |
variable | précision définie par l'utilisateur, exacte | jusqu'à 131 072 chiffres avant la virgule décimale ; jusqu'à 16 383 chiffres après la virgule décimale |
| Nom | Capacité de stockage | Description | Plage |
|---|---|---|---|
decimal ou numeric |
variable | précision définie par l'utilisateur, exacte | jusqu'à 131 072 chiffres avant la virgule décimale ; jusqu'à 16 383 chiffres après la virgule décimale |
real |
4 octets | précision variable, inexact | Précision à 6 chiffres décimaux |
double precision |
8 octets | précision variable, inexact | Précision de 15 chiffres décimaux |
-- integer division
SELECT 10/4;
2
-- numeric division
SELECT 10/4.0;
2.500000000
SELECT min(question_pct)
FROM stackoverflow;
min
-----
0
(1 row)
SELECT max(question_pct)
FROM stackoverflow;
max
-------------
0.071957428
(1 row)
SELECT avg(question_pct)
FROM stackoverflow;
avg
---------------------
0.00379494620059319
(1 row)
Variance de la population
SELECT var_pop(question_pct)
FROM stackoverflow;
var_pop
----------------------
0.000140268640974167
(1 row)
Variance de l'échantillon
SELECT var_samp(question_pct)
FROM stackoverflow;
var_samp
----------------------
0.000140271571051059
(1 row)
SELECT variance(question_pct)
FROM stackoverflow;
variance
----------------------
0.000140271571051059
(1 row)
Écart type de l'échantillon
SELECT stddev_samp(question_pct)
FROM stackoverflow;
stddev_samp
--------------------
0.0118436299778007
(1 row)
SELECT stddev(question_pct)
FROM stackoverflow;
stddev
--------------------
0.0118436299778007
(1 row)
Écart type de la population
SELECT stddev_pop(question_pct)
FROM stackoverflow;
stddev_pop
--------------------
0.0118435062787237
(1 row)
SELECT round(42.1256, 2);
42.13
-- Summarize by group with GROUP BY
SELECT tag,
min(question_pct),
avg(question_pct),
max(question_pct)
FROM stackoverflow
GROUP BY tag;
tag | min | avg | max
--------------------------+-------------+----------------------+-------------
amazon-sqs | 6.91e-05 | 8.08328877005347e-05 | 9.6e-05
amazon-kinesis | 2.1e-05 | 3.3924064171123e-05 | 4.64e-05
android-pay | 2.97e-05 | 3.16712477396022e-05 | 3.29e-05
amazon-cloudformation | 4.8e-05 | 9.34518997326204e-05 | 0.00015246
citrix | 3.6e-05 | 3.95804407713499e-05 | 4.39e-05
amazon-ec2 | 0.001058039 | 0.00122817236730946 | 0.001378872
actionscript | 0.000551486 | 0.00067589990909091 | 0.000856132
amazon-ecs | 1.17e-05 | 3.40544117647059e-05 | 6.51e-05
mongodb | 0.0049625 | 0.00577465885069125 | 0.00631164
amazon-redshift | 0.000117294 | 0.000160832181818182 | 0.000212208
...
Analyse exploratoire des données en SQL