cancel
Showing results for 
Search instead for 
Did you mean: 

HANA Sql query with case statement

0 Kudos

Hi experts,

In sql case statement is it possible to select all fields from a table and then write case in some of the fields that present in that same table without modifying the field name

Example:

SELECT a.* , FROM :lt_data as a LEFT OUTER JOIN :lt_manual AS b ON ( a.billing = b.vbeln );

and the want do case on "a.remark' field which is in structure 'A' without using 'AS" after 'END'

in my case it is giving error so please provide me alternate solution as i have almost 40 field in my output structure

or is there sql like select * fields except one filed from table..

pfefferf
Active Contributor

Please post the statement you are trying to execute and the error you get.

0 Kudos

My sql statement :

LT_SCM = SELECT x.* , CASE x.kunnr WHEN NULL THEN a.CUSTOMER END FROM :lt_scm AS x RIGHT OUTER JOIN :lt_data AS a ON (x.kunnr = a.CUSTOMER) INNER JOIN :lt_manual AS b ON ( a.billing = b.vbeln );

Error : SQLSCRIPT message: return type mismatch: Procedure ZCL_AMDP_BILLING=>GET_SALES_DATA: LT_SCM[ KUNNR:NVARCHAR(10) NAME1:NVARCHAR(30) SHIP_TO_PARTY:NVARCHAR(10) SHIP_TO_NAME:NVARCHAR(30) ORT01:NVARCHAR(25) REGIO:NVARCHAR(25) EBELN:NVARCHAR(10)

Requirement : in 'LT_SCM' Table i have 48 field and i want to change the value of some of the fields by case statement without using Alias as i directly exporting the table 'LT_SCM'

Accepted Solutions (0)

Answers (1)

Answers (1)

shanthi_bhaskar
Active Contributor
0 Kudos

LT_SCM = SELECT x.* , CASE x.kunnr WHEN NULL THEN a.CUSTOMER END as xcustomer FROM :lt_scm AS x RIGHT OUTER JOIN :lt_data AS a ON (x.kunnr = a.CUSTOMER) INNER JOIN :lt_manual AS b ON ( a.billing = b.vbeln );

alias (as xcustomer) is missing

0 Kudos

I dont want to use alias because it will create a different field i want to do it in 'X" itself using select *

problem is that i have 48 fields in table i want all field and only one field want to manipulate during select