1

I’m using SAP Lumira desktop and "Query with SQL (Freehand SQL)", connected to SAP ECC. I try to extend the query with a case statement but run into errors as below:

SELECT "VBUK-UVALS",
           CASE ("VBUK-UVALS") WHEN 'A' THEN 'Closed'
                               WHEN 'B' THEN 'Open'
                               ELSE 'Other'
           END AS "ColumnA"
FROM   "Local"."INFOSET"."ZCA_TESTAR"

Syntax error in SQL query:
[line 2:31 missing FROM at 'WHEN'][line 2:36 missing EOF at "A"]

It would be very appreciated if any could guide me through this

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
BB8
  • 11
  • 2

2 Answers2

0

As the error suggests, your syntax is wrong. A case expression has only one case keyword, and can have multiple when clauses of the different values you're evaluating (and an optional single else clause):

SELECT "VBUK-UVALS",
       CASE ("VBUK-UVALS") WHEN 'A' THEN 'Closed'
                           WHEN 'B' THEN 'Open' -- CASE ("VBUK-UVALS") removed
                           ELSE 'Other'
       END AS "ColumnA"
FROM   "Local"."INFOSET"."ZCA_TESTAR"
Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

Sorry, to many “CASE”, It was a mistake by me when wrote the case. The Query is stated as followed with the same error message

SELECT "VBUK-UVALS",
       CASE ("VBUK-UVALS") WHEN 'A' THEN 'Closed'
                           WHEN 'B' THEN 'Open'
                           ELSE 'Other'
       END AS "ColumnA"
FROM   "Local"."INFOSET"."ZCA_TESTAR"

Syntax error in SQL query: [line 2:27 missing FROM at 'WHEN'][line 2:32 missing EOF at "A"]

BB8
  • 11
  • 2