Hi
Incorrect Syntax near ""
SQL
CASE
WHEN T1."TransType" = '13' THEN (Select max(A0.CardCode") from ONV A0 where A0."TransId" = T1."TransId")
WHEN T1."TransType" = '14' THEN (Select max(A0."LocCode") from ORIN A0 where A0."TransId" = T1."TransId")
End As "Vendor"Thanks

Sophia CarterRank #4,018 · 371 reputationPosted Mar 25, 2025, 1:31 AM EDT
Hi there! It looks like the issue in your SQL query is around the incorrect syntax near the quotation mark in your subqueries. Specifically, in the lines:
(Select max(A0.CardCode") from ONV A0 where A0."TransId" = T1."TransId") (Select max(A0."LocCode") from ORIN A0 where A0."TransId" = T1."TransId")The problem lies with the ending quotation mark in `A0.CardCode"` and the missing backtick in the `Select max(A0."LocCode")` part of your subqueries.
To correct the syntax, you should adjust these lines to:
(SELECT max(A0."CardCode") from ONV A0 where A0."TransId" = T1."TransId") (SELECT max(A0."LocCode") from ORIN A0 where A0."TransId" = T1."TransId")By making these adjustments, you'll have properly formatted subqueries, and your SQL should execute without syntax errors.
If you have any more questions or need further clarification, feel free to ask!
Sangeetha SRank #212 · 11.4K reputationPosted Mar 25, 2025, 3:09 AM EDT
Let's correct it:
CASE WHEN T1."TransType" = '13' THEN (SELECT MAX(A0."CardCode") FROM ONV A0 WHERE A0."TransId" = T1."TransId") WHEN T1."TransType" = '14' THEN (SELECT MAX(A0."LocCode") FROM ORIN A0 WHERE A0."TransId" = T1."TransId") END AS "Vendor"