0
I have a table where there are two fields with possible values: yes-no. The select I’m doing is this:
select
nome,
media,
escola as 'Particular',
bairro as 'COTA DE BAIRRO'
from
alunos
where
curso = 'Enfermagem'
order by
media desc, nome asc,
(CASE WHEN bairro = 'Sim' THEN 0 ELSE 1 END),
(CASE WHEN escola = 'Sim' THEN 0 ELSE 1 END)
In the Particular field, return only 8 values with result 'Yes' and in the neighborhood field 2 values with result 'Yes'. You can’t do it with limit, because limit returns the limit of all the consulted lines, and I wanted you to limit only the number of results with two columns Yes
And if the same record holds
escola='sim'
andbairro='sim'
? It should count both in the 8 private records and in 2 Neighborhood?– Woss
Iiim, is that I’m doing a system of pre enrollment, then I wanted to return a ranking, as we noticed, and the rules of the edict states that needs to have 8 private school students and 2 students with neighborhood quota
– Rene Júnior
So it doesn’t make much sense for him to be considered twice. If the student has already entered by studying in private school, should not take the place of a neighborhood quota, no?
– Woss
has reason, had not thought about it, and in fact, in the previous notices the student with lower average were always the with neighborhood quota
– Rene Júnior