Parul J
Parul J

Reputation: 59

Add Heading to a group of columns in Oracle SQL

Oracle 11g. Oracle Apex 5.1

I need to Merge the columns without merging the data and Add a column heading in Oracle Apex Interactive Report.

For Example I have a table like this: enter image description here

I want the table output like this: enter image description here

How can I achieve the output in Report Select Statement? If I am using below query in Oracle Apex Interactive Report:

TITLE LEFT '    amount_column       Quantity_column'
SELECT Date, Amount1, Amount2, Amount3, Quantity1, Quantity2
FROM   table_name;

I am getting error as: ORA-20001: Query must begin with SELECT or WITH.

Upvotes: 0

Views: 2808

Answers (2)

Parul J
Parul J

Reputation: 59

In oracle Apex 5.1 we can create such groups in Interactive Grid(IG). To create a group, steps are: Go to Attribute of IG -> create Group -> add a name to group.

To assign a group on column, steps are: go to particular column(s) name -> under layout property -> select group name

Save and run the page and it will work.

Upvotes: 1

MT0
MT0

Reputation: 168505

If you are running the query to get a SQL/Plus style textual output (using Crtl-F5 / run-as-script within SQL Developer) then you can use the commands for formatting SQL*Plus reports such as COLUMN and TTITLE to make it appear like your desired result:

Something like (untested):

COLUMN "Date"    FORMAT A9
COLUMN Amount1   FORMAT 9999.99
COLUMN Amount2   FORMAT 9999.99
COLUMN Amount3   FORMAT 9999.99
COLUMN Quantity1 FORMAT 999999999
COLUMN Quantity2 FORMAT 999999999
TTITLE LEFT '              Amount column       Quantity Column'
SELECT "Date", Amount1, Amount2, Amount3, Quantity1, Quantity2
FROM   table_name;

If you want to do it in the grid (using F5 to run the query within SQL Developer) then you are out of luck and it is not possible.

Upvotes: 0

Related Questions