Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invalid Query for Report with Function return sql

Veerendra PatilNov 11 2019 — edited Nov 13 2019

Hi,

I am using APEX 19.1 - Working on Free Cloud ATP.

I have a Classic report region with source Function Returning SQL query.

My query is

SELECT COUNT (department_id) AS department_id_count,

               COUNT (employee_id) AS employee_id_count,

               country_name      AS country_name,

               department_name   AS department_name,

               job_id            AS job_id,

               SUM (commission_pct) AS commission_pct_sum

FROM emp_details_view

GROUP BY country_name,department_name,job_id

However, when I run the report, I get ORA-00904: "D"."A": invalid identifier message

The query generated by APEX when I debug is

SELECT i.*,

       COUNT (*) OVER () AS apex$total_row_count

  FROM (SELECT "A"

        FROM ((SELECT

     /*+ qb_name(apex$inner) */ d."A"

               FROM (SELECT COUNT (department_id) AS department_id_count,

                            COUNT (employee_id) AS employee_id_count,

                            country_name      AS country_name,

                            department_name   AS department_name,

                            job_id            AS job_id,

                            SUM (commission_pct) AS commission_pct_sum

                     FROM emp_details_view

                    GROUP BY country_name,

                             department_name,

                             job_id

                    ) d

              )) i

       ) i

WHERE 1 = 1

   AND ROWNUM <= 1000001

How to resolve this? Please suggest.

Thanks,

Veerendra.

This post has been answered by fac586 on Nov 12 2019
Jump to Answer
Comments
Post Details
Added on Nov 11 2019
14 comments
976 views