Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between union and union all in CDS views

Hi Team,

I have gone through some documents on Union and Union all in CDS views,I got to know that about union all but what is about union in CDS is there any example on Union.

Thanks

Murali

1 ACCEPTED SOLUTION

enric101
Active Contributor

Hi,

According with this reference Abap CDS

  • If the addition ALL is not specified, all duplicate entries are removed from the results set. They are not removed if ALL is specified

In this page have an example:

https://wiki.scn.sap.com/wiki/display/BI/Union+and+Union+All

Regards,

Enric

7 REPLIES 7

enric101
Active Contributor

Hi,

According with this reference Abap CDS

  • If the addition ALL is not specified, all duplicate entries are removed from the results set. They are not removed if ALL is specified

In this page have an example:

https://wiki.scn.sap.com/wiki/display/BI/Union+and+Union+All

Regards,

Enric

0 Kudos

Right Answer

Let me mention that even in the cases when results are the same there can be a difference in SQL elapsed times. When you have UNION the database is responsible for ensuring distinct results and pretty often it goes for a distinct operation.

Especially in cases when the developer knows that there is a field with a different value (or a field combination with always different value combinations) in the branches, UNION ALL can have much better performance.

vvaree
Explorer

A union - It creates a union of rows in the results sets of 2 select statements. A union results set can itself be the left side of a further union. When using union , it removes the duplicates from the result set.

0 Kudos

Yes,Right answer

matt
Active Contributor

I'd hope it's right. It's the same answer given by Enric Castella Gonzalez two years ago...

maheshpalavalli
Active Contributor
0 Kudos

govindmurali,

Small Tip: instead of commenting that it is the correct answer, please click on the accept button on the answer and close the message.