2021-10-22
select 2+2;
| ?column? |
|---|
| 4 |
select now();
| now |
|---|
| 2021-10-23 12:20:37 |
select nm_municip from municipios_basico;
| nm_municip |
|---|
| ACEGUÁ |
| ÁGUA SANTA |
| ALECRIM |
| ALEGRETE |
| AGUDO |
| ALTO FELIZ |
| ALVORADA |
| SILVEIRA MARTINS |
| AJURICABA |
| ALEGRIA |
select nm_municip, pop from municipios_basico order by pop;
| nm_municip | pop |
|---|---|
| ANDRÉ DA ROCHA | 1216 |
| UNIÃO DA SERRA | 1487 |
| ENGENHO VELHO | 1526 |
| COQUEIRO BAIXO | 1528 |
| VISTA ALEGRE DO PRATA | 1540 |
| MONTAURI | 1540 |
| TUPANCI DO SUL | 1562 |
| LAGOA DOS TRÊS CANTOS | 1597 |
| GUABIJU | 1598 |
| CARLOS GOMES | 1606 |
select nm_municip, pop from municipios_basico order by pop desc;
| nm_municip | pop |
|---|---|
| PORTO ALEGRE | 1397364 |
| CAXIAS DO SUL | 433918 |
| PELOTAS | 326850 |
| CANOAS | 322984 |
| SANTA MARIA | 259246 |
| GRAVATAÍ | 255045 |
| VIAMÃO | 237926 |
| NOVO HAMBURGO | 237742 |
| SÃO LEOPOLDO | 213202 |
| RIO GRANDE | 195768 |
select nm_municip, pop from municipios_basico order by pop desc limit 5;
| nm_municip | pop |
|---|---|
| PORTO ALEGRE | 1397364 |
| CAXIAS DO SUL | 433918 |
| PELOTAS | 326850 |
| CANOAS | 322984 |
| SANTA MARIA | 259246 |
select nm_municip as "Município", pop as "População" from municipios_basico order by pop desc limit 5;
| Município | População |
|---|---|
| PORTO ALEGRE | 1397364 |
| CAXIAS DO SUL | 433918 |
| PELOTAS | 326850 |
| CANOAS | 322984 |
| SANTA MARIA | 259246 |
select nm_municip, dom, pop, renda, st_area from municipios_basico where nm_municip='RIO GRANDE';
| nm_municip | dom | pop | renda | st_area |
|---|---|---|---|---|
| RIO GRANDE | 66606 | 195768 | 1334.242 | 2709530436 |
select nm_municip, dom, pop, renda, st_area/1000000 as area from municipios_basico where nm_municip='RIO GRANDE';
| nm_municip | dom | pop | renda | area |
|---|---|---|---|---|
| RIO GRANDE | 66606 | 195768 | 1334.242 | 2709.53 |
select nm_municip, dom, pop, renda from municipios_basico where nm_municip like 'RIO%';
| nm_municip | dom | pop | renda |
|---|---|---|---|
| RIOZINHO | 1448 | 4312 | 744.3333 |
| RIO DOS ÍNDIOS | 1170 | 3588 | 762.0714 |
| RIO GRANDE | 66606 | 195768 | 1334.2420 |
| RIO PARDO | 12745 | 37366 | 893.4769 |
select nm_municip, dom, pop, renda from municipios_basico where nm_municip like '%GRA%';
| nm_municip | dom | pop | renda |
|---|---|---|---|
| ARROIO GRANDE | 6494 | 18408 | 902.6739 |
| IMIGRANTE | 1064 | 3012 | 1105.8000 |
| CERRO GRANDE | 788 | 2415 | 633.0833 |
| CERRO GRANDE DO SUL | 3333 | 10233 | 674.8421 |
| ERVAL GRANDE | 1651 | 5147 | 1086.3636 |
| GRAMADO | 11140 | 32048 | 1813.0896 |
| GRAMADO DOS LOUREIROS | 722 | 2244 | 686.2222 |
| GRAMADO XAVIER | 1215 | 3967 | 835.2500 |
| GRAVATAÍ | 82378 | 255045 | 1154.2715 |
| HULHA NEGRA | 1926 | 5989 | 959.0000 |
select nm_municip, dom, pop, renda from municipios_basico where nm_municip ilike '%gra%';
| nm_municip | dom | pop | renda |
|---|---|---|---|
| ARROIO GRANDE | 6494 | 18408 | 902.6739 |
| IMIGRANTE | 1064 | 3012 | 1105.8000 |
| CERRO GRANDE | 788 | 2415 | 633.0833 |
| CERRO GRANDE DO SUL | 3333 | 10233 | 674.8421 |
| ERVAL GRANDE | 1651 | 5147 | 1086.3636 |
| GRAMADO | 11140 | 32048 | 1813.0896 |
| GRAMADO DOS LOUREIROS | 722 | 2244 | 686.2222 |
| GRAMADO XAVIER | 1215 | 3967 | 835.2500 |
| GRAVATAÍ | 82378 | 255045 | 1154.2715 |
| HULHA NEGRA | 1926 | 5989 | 959.0000 |
select sum(pop) from municipios_basico;
| sum |
|---|
| 10629866 |
select sum(pop) from municipios_basico where nm_municip != 'PORTO ALEGRE';
| sum |
|---|
| 9232502 |
select avg(renda) from municipios_basico;
| avg |
|---|
| 1083.778 |
e < (maior, menor)
= e <= (maior igual, menor igual)