Skip to content
Snippets Groups Projects
Commit 10d97e1c authored by Fernando Gbur dos Santos's avatar Fernando Gbur dos Santos
Browse files

[ADD] Trying to fix the join problem

parent dd8b92a0
No related branches found
No related tags found
3 merge requests!449Homologa,!444dev -> hom,!441Years of study mean
...@@ -300,14 +300,14 @@ rqf.addField({ ...@@ -300,14 +300,14 @@ rqf.addField({
foreignTable: 'pnad_novo' foreignTable: 'pnad_novo'
} }
}).addValue({ }).addValue({
name: 'years_of_study', name: 'location',
table: 'pnad_novo', table: 'pnad_novo',
tableField: 'anos_de_estudo', tableField: 'situacao_domicilio',
resultField: 'years_of_study_id', resultField: 'location_id',
where: { where: {
relation: '=', relation: '=',
type: 'integer', type: 'integer',
field: 'anos_de_estudo' field: 'situacao_domicilio'
} }
}).addValue({ }).addValue({
name: 'instruction_level', name: 'instruction_level',
...@@ -378,7 +378,7 @@ rqf.addField({ ...@@ -378,7 +378,7 @@ rqf.addField({
relation: '=', relation: '=',
type: 'integer', type: 'integer',
field: 'turno_nivel_etapa' field: 'turno_nivel_etapa'
} }
}).addValue({ }).addValue({
name: 'bolsa_familia', name: 'bolsa_familia',
table: 'pnad_novo', table: 'pnad_novo',
...@@ -482,7 +482,7 @@ rqf.addField({ ...@@ -482,7 +482,7 @@ rqf.addField({
}).addField({ }).addField({
name: 'search', name: 'search',
field: false, field: false,
where: true where: true
}).addValueToField({ }).addValueToField({
name: 'name', name: 'name',
table: 'pnad_novo', table: 'pnad_novo',
...@@ -514,6 +514,15 @@ rqf.addField({ ...@@ -514,6 +514,15 @@ rqf.addField({
PnadNovoApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { PnadNovoApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
let teste = "pnad_novo.ano_ref = media.ano_ref"
if (req.dims) {
for (i in req.dims) {
teste += ` and pnad_novo.${i.table} = media.${i.tableField}`
}
}
console.log(teste)
let mean = squel.select() let mean = squel.select()
.from('pnad_novo') .from('pnad_novo')
.field('pnad_novo.ano_ref', 'ano_ref') .field('pnad_novo.ano_ref', 'ano_ref')
...@@ -525,7 +534,7 @@ PnadNovoApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { ...@@ -525,7 +534,7 @@ PnadNovoApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.field('pnad_novo.ano_ref', 'year') .field('pnad_novo.ano_ref', 'year')
.field('media.media_anos_estudo', 'mean') .field('media.media_anos_estudo', 'mean')
.field('SQRT(SUM((POWER(pnad_novo.anos_de_estudo - media.media_anos_estudo, 2) * pnad_novo.peso_domicilio_pessoas_com_cal)) / SUM(pnad_novo.peso_domicilio_pessoas_com_cal))', 'std_dev') .field('SQRT(SUM((POWER(pnad_novo.anos_de_estudo - media.media_anos_estudo, 2) * pnad_novo.peso_domicilio_pessoas_com_cal)) / SUM(pnad_novo.peso_domicilio_pessoas_com_cal))', 'std_dev')
.join(mean, 'media', 'pnad_novo.ano_ref = media.ano_ref') .join(mean, 'media', teste)
.where('pnad_novo.ano_ref >= 2019') .where('pnad_novo.ano_ref >= 2019')
.group('pnad_novo.ano_ref') .group('pnad_novo.ano_ref')
.group('media.media_anos_estudo') .group('media.media_anos_estudo')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment