none
Nested SQL select query format problem RRS feed

  • Question

  • My sql query isn't being accepted. I keep getting ORA-00907, ORA-00933 or ORA-00979 errors. Can any one see what is wroing with the syntax?

    SELECT A.YEAR_I AS YEAR_I ,
    TRUNC(A.DATE_M) AS DATE_M ,
    A.TYPE_M AS TYPE_M ,
    ROUND((A.RATE_I * 100), 4) AS RATE_I ,
    SUM(NVL(A.AMT_P,0)) AS AMT_P ,

    (SELECT SUM(NVL(B.AMT_P,0)) AS prior_amt_p
    FROM TABLE_I B
    WHERE ACCOUNTING_PERIOD_YEAR = {?from_accounting_period_year}
    AND ACCOUNTING_PERIOD_NBR < {?from_accounting_period}
    AND A.YEAR_I = B.YEAR_I
    AND TRUNC(A.DATE_M) = TRUNC(B.DATE_M)
    AND A.TYPE_M = B.TYPE_M
    AND A.RATE_I = B.RATE_I
    GROUP BY B.YEAR_I ,
    TRUNC(B.DATE_M),
    B.TYPE_M ,
    B.RATE_I ,
    B.AMT_P
    ORDER BY B.YEAR_I ,
    TRUNC(B.DATE_M),
    B.TYPE_M ,
    B.RATE_I),

    SUM(NVL(NO_OF_DAYS,0)) AS NO_OF_DAYS
    FROM TABLE_I A
    WHERE ACCOUNTING_PERIOD_YEAR = {?from_accounting_period_year}
    AND ACCOUNTING_PERIOD_NBR = {?from_accounting_period}
    GROUP BY A.YEAR_I ,
    TRUNC(A.DATE_M),
    A.TYPE_M ,
    A.RATE_I
    ORDER BY A.YEAR_I ,
    TRUNC(A.DATE_M),
    A.TYPE_M ,
    A.RATE_I

    (Crystal report in VB 2005)
    • Moved by Harry Zhu Friday, February 26, 2010 2:22 AM (From:Crystal Reports for Visual Studio)
    Friday, February 19, 2010 9:08 PM

All replies

  • Hi,

    The question relating to MySql is beyond the scope of this forum , I suggest you try Mysql forum for better help.

    Thanks,
    Harry
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, February 25, 2010 6:02 AM