Application Development and Automation 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: 
Read only

Is it possible to do nested select on DDL / SQL?

5,247

I have a problem with the nested select, I just want to select the text when custtype = B,

can you suggest an approach that I can try to implement for this solution? Thank you!

the 1st one is SQL console,

2nd one is CDS DDL

3 REPLIES 3
Read only

maheshpalavalli
Active Contributor
0 Likes
4,360

Hi mchua9,

It's currently not possible in ABAP CDS, but you an do this in an another way using left outer join. check out the code below:

@AbapCatalog.sqlViewName: 'ZVSBOOKSTEST'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'test'
define view zsbookstest as select from sbook 
                           left outer join sbuspart
                                        on sbuspart.buspartnum = sbook.customid
                                       and sbook.passname is initial {
    sbook.bookid,
    case when passname is initial then sbuspart.contact else passname end as passname
}


-Mahesh

Read only

0 Likes
4,359

ok thanks, that's too bad then..

this is now my working code. it seems like when you add "and sbook.passname isinitial" from outside the clause runtime is slower though its just around ~10-15ms per 5000 line on 10 runs I have tried

Read only

4,359

great!, I didn't know adding where clause of is initial in join will slow it donw,, i thought we will be filtering unrequired data.. Thanks for the tip.

You can close the question if your query is answered.

https://blogs.sap.com/2017/08/15/what-to-do-with-my-answered-questions/