Skip to content
Advertisement

Query optimization for multiple inner joins and sub-query

I need help regarding query optimization of the below query.

Since there are duplicate joins in the main query and sub query, is there any way to remove those joins in the subquery?

Advertisement

Answer

Since, as you clarified, your sub-query is almost identical to your main query you might be able to use the window function RANK as a filter condition. RANK assigns the same number to ties, meaning if multiple records per company match you will get them all e.g.

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