Skip to content
Advertisement

Avoid duplicate entries using full JOIN with SUM and GROUP BY

I am using HSQLDB for the database and have the following condition in which I have to avoid duplicate entries while joining 2 tables.

Table1

Table2

The current query which gives me the duplicate entries is as follows

OUTPUT

And if I use this above-mentioned query to get the actual output which is required in my actual scenario is as follows

OUTPUT

The requirement is to get the sum of amount for a single day and null entry for the date which is not present in another table.

Expected output is as follows

C3 and C4 column values are not calculated correctly due to the duplicate entries.

Help…

Advertisement

Answer

One method to solve this uses union all and group by:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement