I have the following SQL code in DB2:
SELECT p.nome_pessoa, a.dt_nascimento, alc.matricula, d.numero_documento, d.id_tdoc_pessoa FROM pessoas as p
INNER JOIN alunos as a ON p.id_pessoa = a.id_pessoa
INNER JOIN acad_alunos_cursos as alc ON alc.id_aluno = a.id_aluno
INNER JOIN doc_pessoas as d ON p.id_pessoa = d.id_pessoa WHERE p.nome_pessoa = 'Vitor Lucas Pires Cordovil'
After executing the query I have the following return:
NAME - DATE OF BIRTH - REGISTRATION - NUMBER DOCUMENT - DOCUMENT TYPE
Vitor Lucas Pires Cordovil - 1994-02-27 - 2014300028 - 951.249.865-X3 - 1
Vitor Lucas Pires Cordovil - 1994-02-27 - 2012430028 - 10491872 - 3
It returns me the two records, because there are two documents registered to the person, when the document type is 1 then it is an RG, when it is 3 is a CPF. But I want the query to return only one record with two columns: RG and CPF, all on the same line. How to make?