Results 1 to 2 of 2
  1. #1
    Join Date
    May 2013
    Posts
    1

    Unanswered: Error in query of combine sum in single query

    Hi Chandra,

    thank you so much for your quick response...
    I tried using the new script , I still encounter the same issue . Did I miss out something?

    Processing ended because the highlighted statement did not complete successfully

    > IF EXISTS ( SELECT 1 FROM PRODDTA.F55SWF WHERE SWADDS in ('LBN', 'SBH')) THEN SELECT SWFYEAR AS FisYear ,SWAC01 AS Agency ,SWADDS AS State ,SWSRP1 AS Brand ,SWSRP2 AS SubBrand ,SWSRP4 AS Range ,SUM(SWC9QTY1) AS JanQty ,SUM(SWC9QTY2) AS FebQty FROM PRODDTA.F55SWF where SWADDS in ('LBN', 'SBH') GROUP BY SWFYEAR, SWAC01, SWADDS, SWSRP1, SWSRP2, SWSRP3, SWSRP4, SWSRP0 ORDER BY (CASE WHEN SWADDS = 'JHR' THEN 1 WHEN SWADDS = 'MLK' THEN 2 ELSE 3 END), State, FisYear DESC, (CASE WHEN SWSRP1 = 'PAL' THEN 1 ELSE 2 END) ELSE SELECT SWFYEAR AS FisYear, SWAC01 AS Agency, SWADDS AS State, SWSRP1 AS Brand, SWSRP2 AS SubBrand, SWSRP4 AS Range, SUM(SWC9QTY1) AS JanQty, SUM(SWC9QTY2) AS FebQty FROM PRODDTA.F55SWF where SWADDS NOT IN ('LBN', 'SBH') GROUP BY SWFYEAR, SWAC01, SWADDS, SWSRP1, SWSRP2, SWSRP3, SWSRP4, SWSRP0 ORDER BY (CASE WHEN SWADDS = 'JHR' THEN 1 WHEN SWADDS = 'MLK' THEN 2 ELSE 3 END), State, FisYear DESC, (CASE WHEN SWSRP1 = 'PAL' THEN 1 ELSE 2 END) END IF

    SQL State: 42601
    Vendor Code: -199
    Message: [SQL0199] Keyword IF not expected. Valid tokens: ( CL END GET SET CALL DROP FREE HOLD LOCK OPEN WITH ALTER BEGIN. Cause . . . . . : The keyword IF was not expected here. A syntax error was detected at keyword IF. The partial list of valid tokens is ( CL END GET SET CALL DROP FREE HOLD LOCK OPEN WITH ALTER BEGIN. This list assumes that the statement is correct up to the unexpected keyword. The error may be earlier in the statement but the syntax of the statement seems to be valid up to this point. Recovery . . . : Examine the SQL statement in the area of the specified keyword. A colon or SQL delimiter may be missing. SQL requires reserved words to be delimited when they are used as a name. Correct the SQL statement and try the request again.

    Processing ended because the highlighted statement did not complete successfully

  2. #2
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    This appears to be a reply to some topic.

    If you tell us where the original topic is located, maybe this one can join it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •