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

SQL "inline declaration must have alias" error for substring

former_member625844
Participant
7,007

I wrote a SQL like below..

SELECT substring( cosp_bak~objnr,7,10 ),
        cosp_bak~kstar,
        cosp_bak~wkg001,cosp_bak~wkg002,cosp_bak~wkg003,cosp_bak~wkg004,cosp_bak~wkg005,cosp_bak~wkg006,cosp_bak~wkg007,cosp_bak~wkg008,cosp_bak~wkg009,
        cosp_bak~wkg010,cosp_bak~wkg011,cosp_bak~wkg012
        FROM cosp_bak
        WHERE
        cosp_bak~wrttp = '01'
        and cosp_bak~vrgng = 'RKP1'
        AND cosp_bak~gjahr = @s_gjahr
        AND cosp_bak~objnr in @t_objnr 
        INTO TABLE @DATA(gt_data_p).

And it has error below. It looks like the error is caused by the substring function. then How to add alias name for it? Thanks.

inline declarations are used, all expressions in the projection list must have an alias name.
1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
3,677

Hello loki_luo15

SELECT substring( cosp_bak~objnr,7,10 ) AS DESIRED_COLUMN_NAME,
Kind regards,
Mateusz
2 REPLIES 2
Read only

MateuszAdamus
Active Contributor
3,678

Hello loki_luo15

SELECT substring( cosp_bak~objnr,7,10 ) AS DESIRED_COLUMN_NAME,
Kind regards,
Mateusz
Read only

diwaneamit
Participant
0 Likes
3,677

Hello loki_luo15

Whenever you are using any functions with Select in the selection of fields you need to provide an alias name for the field. Same you have to do here after the substring function.

Regards,

Amit