This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; | |
set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
GROUP_CONCAT(contas.nome) AS contas, | |
classificacao.nome AS classificacao | |
FROM | |
contas | |
INNER JOIN | |
classificacao ON classificacao.id = contas.id_classificacao | |
GROUP BY classificacao.nome; | |
+------------------------------------------------------------+---------------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT contas.nome AS conta, classificacao.nome AS classificacao FROM contas INNER JOIN classificacao ON classificacao.id = contas.id_classificacao; | |
+-----------------------------+---------------+ | |
| conta | classificacao | | |
+-----------------------------+---------------+ | |
| Salario | receita | | |
| Rendimento de investimentos | receita | | |
| Recebimento de aluguel | receita | | |
| Conta de água | despesa | | |
| Conta de luz | despesa | | |
| Jogos da Steam | despesa | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT GROUP_CONCAT(nome) FROM contas; | |
+-------------------------------------------------------------------------------------------------------+ | |
| GROUP_CONCAT(nome) | | |
+-------------------------------------------------------------------------------------------------------+ | |
| Salario,Rendimento de investimentos,Recebimento de aluguel,Conta de água,Conta de luz,Jogos da Steam | | |
+-------------------------------------------------------------------------------------------------------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT nome FROM CONTAS; | |
+-----------------------------+ | |
| nome | | |
+-----------------------------+ | |
| Salario | | |
| Rendimento de investimentos | | |
| Recebimento de aluguel | | |
| Conta de água | | |
| Conta de luz | | |
| Jogos da Steam | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT COUNT(id) FROM livros; | |
+-----------+ | |
| COUNT(id) | | |
+-----------+ | |
| 20000 | | |
+-----------+ | |
1 row in set (0.00 sec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE index indice_por_lancamento ON livros(data_de_lancamento); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
*, | |
(SELECT | |
COUNT(l2.data_de_lancamento) | |
FROM | |
livros AS l2 | |
WHERE | |
l2.data_de_lancamento = l.data_de_lancamento) AS vendas_anteriores | |
FROM | |
livros AS l; |
NewerOlder