Select with duplicate record

1

I have a question that may be trivial for most, but that I got stuck here, I look for a lot of research before posting, but I'll need a help.

I'm building a select to bring me the closing of the results with base date, for this I need, for example, to take as base 12/31/2015, in the structure of the database the tables that will be queried will be document , the document table contains the generated documents and document_pgto records payment events (1 or more) for each document.

Thanks

    
asked by anonymous 31.03.2016 / 14:11

2 answers

0

Change 'group by' to:

group by s1.cod_empresa,
       s1.num_docum

Do this and pass the feedback. I think it works out.

    
31.03.2016 / 14:47
0

By drawing your select I do not see a way to return the fields you want to return, you get the result you want.

You could make a group by but this would mean not having the amount of returns you want.

You could use distintc but you would also have to omit some campuses in your selection.

You could also use rank , which would change the direction of your query, and remove the duplicates.

But none of these solutions meets your need.

    
01.11.2017 / 15:49