This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| """script_vista_teste.ipynb | |
| Original file is located produced at Google Collab | |
| IMPORTANTE: coloque o link do seu extrato csv da Noh antes de rodar os códigos. | |
| IMPORTANTE2: modifique o nome do arquivo que será gerado na ultima linha de código antes de exportar. | |
| """ |
This file contains hidden or 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(distinct empregado.matr) as qnt_empregados, | |
| departamento.nome as nome_departamento, | |
| round(avg(coalesce(vencimento.valor, 0)), 2) as avg_salarios, | |
| min(coalesce(vencimento.valor, 0)) as min_salarios, | |
| max(coalesce(vencimento.valor, 0)) as max_salarios | |
| from empregado | |
| join departamento on departamento.cod_dep = empregado.lotacao | |
| join emp_venc on emp_venc.matr = empregado.matr | |
| join vencimento on emp_venc.cod_venc = vencimento.cod_venc | |
| where vencimento.nome ilike 'salario%' --caso queira considerar todos os tipos de valores recebidos, como auxílios e gratificações também, retirar essa linha |
This file contains hidden or 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
| -- a CTE já apresenta o resultado da questão 1a | |
| with student_price_per_school as ( | |
| select | |
| count(students.id) as qnty_students, | |
| students.enrolled_at, | |
| schools.name as school_name, | |
| sum(price) as enrollment_price | |
| from | |
| courses | |
| join schools on courses.school_id = schools.id |