1
Hello!
I’m having a hard time developing a logic for a bank search.
I need to return from the bank a table with the student list enrolled with a certain type of voucher.
But each student can have N vouchers assigned to his registration.
To illustrate, I made this voucher table. All students have the A voucher, but I need a select that returns those who have exclusively the type A. Students 002 and 003 should not enter the search since they have the B and/or C as well.
How can I do that?
My appointment is like this
SELECT P.COD_ALUNO, P.NOME, P.ID_TIPO_PESSOAS
FROM TB_VOUCHER V
INNER JOIN TB_PESSOAS P ON P.COD_ALUNO = V.COD_ALUNO
WHERE
V.TIPO_VOUCHER = 239 AND
V.COD_ALUNO IS NOT NULL AND
P.ID_TIPO_PESSOAS = 10
type in the question the select/from/Where you have done so far
– Ricardo Pontual
Search for vouchers = A and using the NOT EXISTS clause make a subsect for the student with a <> A voucher.
– anonimo
edit the question and put the full query there, it is better to view
– Ricardo Pontual
placed the query. are two tables that pick up students with voucher 239 and who are with active enrollment
– Júnior Lobo