Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why I am getting '[Error] Execution (48: 50): ORA-00936: missing expression'

      SELECT CASE
            WHEN(SELECT TO_CHAR(A.BILL_DT, 'MM') )  >= 4
            THEN
               CONCAT (SELECT TO_CHAR(A.BILL_DT, 'YYYY') ),(SELECT TO_CHAR(A.BILL_DT+1, 'YYYY')  )
            ELSE
               CONCAT (SELECT TO_CHAR(A.BILL_DT, 'YYYY')  ) - 1, (SELECT TO_CHAR(A.BILL_DT, 'YYYY')   ))
         END AS FY,
         SUM (A.BILL_AMT)
    FROM REVADMIN.REV_BILL_HEADER A
GROUP BY CASE
            WHEN (SELECT TO_CHAR(A.BILL_DT, 'MM')  ) >= 4
            THEN
               CONCAT(SELECT TO_CHAR(A.BILL_DT, 'YYYY')), (SELECT TO_CHAR(A.BILL_DT, 'YYYY')) + 1)
            ELSE
               CONCAT (SELECT TO_CHAR(A.BILL_DT, 'YYYY' )) - 1, (SELECT TO_CHAR(A.BILL_DT, 'YYYY' ))
         END;   

This supposed to be true but still getting error why am getting missing expression error

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Remove SELECT from CASE expression; just use column from the table in FROM clause.

For simplicity, I also removed concat and used the double pipe || concatenation operator.

(Though, I’m not sure what is that piece of code supposed to return, doesn’t make much sense to me but I guess you know.)

  SELECT CASE
            WHEN TO_CHAR (A.BILL_DT, 'MM') >= 4
            THEN
               TO_CHAR (A.BILL_DT, 'YYYY') || TO_CHAR (A.BILL_DT + 1, 'YYYY')
            ELSE
               TO_CHAR (A.BILL_DT, 'YYYY') - 1 || TO_CHAR (A.BILL_DT, 'YYYY')
         END AS FY,
         SUM (A.BILL_AMT)
    FROM REVADMIN.REV_BILL_HEADER A
GROUP BY CASE
            WHEN TO_CHAR (A.BILL_DT, 'MM') >= 4
            THEN
               TO_CHAR (A.BILL_DT, 'YYYY') || TO_CHAR (A.BILL_DT + 1, 'YYYY')
            ELSE
               TO_CHAR (A.BILL_DT, 'YYYY') - 1 || TO_CHAR (A.BILL_DT, 'YYYY')
         END
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading