Hi @KaustubaTM1 ,
AEM SQL2 doesnt support keyword "UNION", instead use "JOIN".
However, there should be a relation between both nodes like a parent-child, So then it will work.
I'm giving such an example for your quick referance, But if you want to deep dive & learn more. try link given above.
S...