Skip to content
Advertisement

Avoid duplicate in query and make all the duplicated row blank

I have written query which should fetch ADJUSTMENT_AMOUNT and PAY_AMOUNT from the table ABC for different month, I have used subqueries to get this done, each ADJUSTMENT_AMOUNT and PAY_AMOUNT contains number, which is addition of multiple rows for the month by that each month I can see how much adjustment amount is available, same with PAY_AMOUNT.

But with the query that I have written, it is failing when ADJUSTMENT_AMOUNT is calculated using june,july,august,september month but PAY_AMOUNT is calculated using only september month, here in this condition PAY_AMOUNT is duplicated. I just want to avoid the duplicate values and make it blank, so basically only one row should be available for PAY_AMOUNT and rest 3 rows should be blank.

My query:

Advertisement

Answer

Adding to points mentioned by (kfinity) and assuming the sub-queries are working fine. The below query will give all the data from the first sub-query and if it has any co-related data in the second query you get it, else the columns from query b will be null.

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