I have two tables MASTER_TABLE and DOCUMENTS table. Both are related with a column reference_id. DOCUMENTS table has columns doc_id,doc_type and doc_creation_date
We can have more than one entry in DOCUMENTS table for each doc_type with different doc_creation_date. My aim is to fetch the doc_type and doc_id for each doc_type in a single row for the max doc_creation_date
MASTER_TABLE
REFERENCE_ID COLUMN1 COLUMN2
1 DATA1 DATA2
2 DATA3 DATA4
3 DATA5 DATA6
DOCUMENTS
REFERENCE_ID DOC_ID DOC_TYPE DOC_CREATION_DATE
1 11 PDF 16/06/2017
1 12 XLS 16/06/2017
1 13 TXT 16/06/2017
1 14 PDF 15/06/2017
1 15 XLS 15/06/2017
1 16 TXT 15/06/2017
2 17 PDF 16/06/2017
2 18 XLS 16/06/2017
2 19 TXT 16/06/2017
EXPECTED OUTPUT
REFERENCE_ID DOC_ID_PDF DOC_ID_XLS DOC_ID_TXT
1 11 12 13
2 17 18 19
Is this possible to achieve using a single query. I tried a self join and pivot but guess am doing it the wrong way. We have Oracle 11g and 12c databases that we can use.