Summary column in a union query....
hi,
i've a report. the datamodel is like ....
select inv_total,inv_id from invoices
union all
select -pymt_total,pymt_id from payments
union all
select misc_total,misc_id from transactions
where misc_code='D'
union all
select -misc_total,misc_id from transactions
where misc_code='C'
this will give me output for all the customers. i want to print total for
inv_total+pymt_total+misc_total+misc_total which will reset at customer id.
Can i create a summary column that will reset at customer id column? i'm using reports 3.0.8
thanks
---himanshu
1) Add customer_no to the SELECT as column3.
2) Create 2 groups of the query: G1 with customer_no and G2 with the other 2 columns.
3) Create a summary column (Use the toolbar on the left, the symbol has the Sigma sum symbol). Choose column 1 as the column to sum. Set it to re-set at G1 (I think default is Report).
John Alexander www.SummitSoftwareDesign.com
Similar Messages
-
Can I reference a Summary Column in my sql query?
Basically the subject asks it all. I have a very complex report that has many data linked queries from the "main" query. One of these data linked queries has a sub-query within it that references the primary key of the main query. I can't data link (I can, but it's useless) using this field as it's a sub-query that needs the link, and that link specifically. I've tried to create a Summary Column that gives me the "First" (and only, so it's safe) in order to reference it in the SQL block, but no go. I'm thinking this isn't even possible? Anyone have any ideas? Right now I'm referencing it as I would in a PL/SQL block (:CS_PK), but it's just treated as a parameter that's never passed. Doesn't read the summary column. Hmmm... I'm stuck.
Hi all... this report is still not completed. I've tried the summary column, and created a formula column that sets the user parameter to the primary key that's needed elsewhere. The report runs, no errors, but my best guess is that it's simply not reading that formula column. Here's my formula column:
function CF_1FORMULA0024 return Number is
begin
if :tblassessmentinst is null then
:tblassessmentinst := :CA_ASSESS_INST;
elsif :tblassessmentinst is NOT null then
:tblassessmentinst := :CA_ASSESS_INST; -- this WAS :tblassessmentinst but not working with prod ver, so delay
else
:tblassessmentinst :=0;
end if;
return(:tblassessmentinst);
end;
For testing, I display both the :tblassessmentinst on the report, as well as this formula column. The formula column always displays the correct number, but the :tblassessment only displays 1 (of many) records that need to be displayed. It's like it's not refreshing the formula column for each record? Again, still super stumped, so throw any ideas my way please.
Thanks again,
TL -
How to get Average of a column in UNION query
Hi All,
I will try to explain the issue as much as I can and If you need clarification on any piece please let me know.
So, I have a Union Query with two sets of Criteria.
The first Criteria Brings the list of Buildings and a set of Measures for it. The second criteria does the same but with a different set of filters.
No I use a UNION between these both criteria and present them in a Pivot view so that we only have one row per each building. The values in each of the criteria in the UNION query are Summed
Ex:
Building
Metric 1
Metric 2
1
20
30
1
25
35
2
40
50
2
45
55
So as I show in the pivot the result is
Building
Metric 1
Metric 2
1
45
65
2
85
105
Now the issue is with the Grand Total.
I want the Grand Total to be an Average of the Buildings. So for Metric 1 The Grand Total should be (45+85)/2 because we have two buildings so the answer should be 65.
How can I get that.
Bottom Line: Need an Average as the Grand Total when the Aggregation rule on the column is set to Sum.
we use 11.1.6.10 versionHi VJ
What you are asking is impossible in the pivot table itself as you are asking one part of the pivot table to aggregate via one method, and another to aggregate via another method, on the same column ..
It can be done using a calculated item. For your example above you'd use the formula ( $1 + $2) / 2.
.. But thats HIGHLY explicit, and would only work if you KNOW how many buildings will come back in the query.. EVERYTIME.
Why not restructure the query to combine it into a single query using an combinations of filters with OR in between? -
Sorting by summary column, query based on previous query.
Using 10g reports.
I've got a report with one query currently thats broken down itno a couple groups. I'm trying to change the order they are displyed by based on a summary count of each group. I'm also trying to do another query for the report based on the results of the first one and display that with the information from the first.
The report currently:
Chain name
ABC Stores
Month
JUN
Store Name Store ID bad sales
Store1 storeid1 5
Store2 storeid2 3
Store3 storeid3 1
month total: 9
JUL
Store1 storeid1 6
Store2 storeid2 5
Store3 storeid3 2
month total:13
Chain total 22
XYZ Stores
JUN
Store1 storedid1 20
Store2 storedid2 15
month total 35
JUL
Store1 storedid1 11
Store2 storedid2 7
month total 18
Chain total 53What I want to do is sort the order the store chains appear in based on the CHain total of bad sales. This is a summary done by the report and not in the sql query at the moment. I would also like to create a second query where it takes the store id and month from the first query and uses it to look up the total sales each store did so I can determine what percentage of the total sales the bad sales were. I would like to add this column plus a calculated percentage column to the right of the current columns but still have them grouped as they are. Is this possible to do or will i need to change my original query?
Not very familiar with reports and I haven't been able to find anything to indicate how this should/could be done yet. Any help is appreciated.hi,
there is no break order property for summary columns .
so use the group by and take the sorting order for whole group
example:
SELECT DEPTNO, JOB, ENAME, SAL FROM EMP
ORDER BY SAL
You then create two groups, G_DEPT and G_JOB. G_DEPT contains
the DEPTNO column and G_JOB contains the JOB column. If you
specify a Break Order of Descending for the DEPTNO column and
Ascending for the JOB column, your output would appear similar
to that below (assuming you use a Tabular style):
Deptno Job Ename Sal
30 CLERK JAMES 950.00
MANAGER BLAKE 2850.00
SALESMAN WARD 1250.00
MARTIN 1250.00
TURNER 1500.00
ALLEN 1600.00
20 ANALYST SCOTT 3000.00
FORD 3000.00
CLERK SMITH 800.00
ADAMS 1100.00
MANAGER JONES 2975.00
10 CLERK MILLER 1300.00
MANAGER CLARK 2450.00
PRESIDENT KING 5000.00 -
Access Summary column in a query
Hi All,
I am new to oracle reports. I am using report builder 10.1.2.0.2.
I have a summary column in my report. I would like to use this summary column in another query.
if is use this column directly in the query, i am getting the below error:
"Field 'F1' references column '<summary column name>' at a frequency below its group. "
Both these fields are in the same frame. In the object navigator, both are displayed under the same group name.
please let me know if there any way to access summary columns in another query.
Thanks.You can use a field from one query in another query as parameter, i.e. preceded by colon. To do this first create link of "Group to Query" type between the first query's group where the summary column is, and the second query.
-
hi, i am using oracle 10g database..
how to get the sum of column in union query ?
select * from (select 100 records from dual), (select 50 available from dual)
union
select * from (select 200 records from dual), (select 150 available from dual)
display should be like
records available
100 50
200 150
total 300 200thanks ...Peter vd Zwan wrote:
try this:Grouping by records will not produce correct results:
SQL> with a as
2 (
3 select * from (select 100 records from dual), (select 50 available from dual)
4 union
5 select * from (select 100 records from dual), (select 100 available from dual)
6 union
7 select * from (select 200 records from dual), (select 150 available from dual)
8 )
9 select
10 case when grouping(records) = 0 then null else 'total' end tot
11 ,sum(records) records
12 ,sum(available) available
13 from
14 a
15 group by
16 rollup (records)
17 ;
TOT RECORDS AVAILABLE
200 150
200 150
total 400 300
SQL> select case grouping(rownum)
2 when 1 then 'Total'
3 end display,
4 sum(records) records,
5 sum(available) available
6 from (
7 select * from (select 100 records from dual), (select 50 available from dual)
8 union
9 select * from (select 100 records from dual), (select 100 available from dual)
10 union
11 select * from (select 200 records from dual), (select 150 available from dual)
12 )
13 group by rollup(rownum)
14 /
DISPL RECORDS AVAILABLE
100 50
100 100
200 150
Total 400 300
SQL> SY. -
Summary Column and repeating frames
I have a report that shows customer orders(1 per page). If a customer orders 3 pizzas and 2 of them are identical, same size, same toppings, crust i want the quanitity column to sum as 2. So for this example instead of having 3 rows with two of them being identical with the quanity column dispalying 1 for each, I want 2 rows with quanity showing 2 for the identical pizzas and 1 for the other.
I have everything in the same group/repeating frame right now and it is showing all 3 pizzas on there own row. Do i need a summary column and change my groupings? How can i achieve this the summed quanity for identical orders?
CURRENT:
Crust......Toppings......size.....quantity
Thin.......Cheese........small....1
Thin.......Cheese........small....1
thick.......meat.........large....1
NEW:
Crust......Toppings......size.....quantity
Thin.......Cheese........small....2
thick.......meat.........large....1Forget summary columns. This can easily be just a group by query:
with t as (select 'Thin' crust, 'Cheese' top ,'Small' sze, 1 qty from dual
union all
select 'Thin' , 'Cheese' ,'Small' , 2 from dual
union all
select 'Thick' , 'Meat' ,'Large', 1 from dual
select t.crust, t.top, t.sze, sum(qty)
from t
group by crust,top,sze;
CRUST TOP SZE SUM(QTY)
Thin Cheese Small 3
Thick Meat Large 1 -
Summary column with where clause
Hi all,
I'm using Oracle Report Builder 10GR2. I have the following issue: In one of the query i have the following result :
Suppliers 0
Suppliers 1408
Total in BGN 1408
Customers 6024
Customers 11779.32
Customers
Total in BGN 11779.32
Taxes 0
Taxes 0
Total in BGN 0
Cash 1363.85
Cash 691
Cash 991.23
Cash 688
Total in BGN 2355.08I want to make a sum for these columns where corresponds to description " Total in BGN" . Maybe it is a simple task... Do i have a chance to select from a query in a Report Builder?
If yes, pls specify? Or maybe there is a chance to add a where clause for summary column. But keep in mind that this is one of the queries in the report builder and i have to add summary with this conditions. I cannot change the existing query but probably add a new one.
Any ideas?
DB Version: 11g
Thanks in advance,
Bahchevanov.
Edited by: bahchevanov on Sep 29, 2012 2:21 AMHello,
You should use parameter file.Another question i can see you are using 11g.Why don't you use data pump?.
Data Pump is faster and have more features and enhancement than regular imp and exp.
You can do the following:
sqlplus / as sysdba
Create directory DPUMP_DIR3 for 'Type here your os path that you want to export to';then touch a file:
touch par.txt
In this file type the following the following :
tables=schema.table_name
dumpfile=yourdump.dmp
DIRECTORY=DPUMP_DIR3
logfile=Your_logfile.log
QUERY =abs.texp:"where hiredate>'01-JAN-13' "then do the following
expdp username/password parfile='par.txt'
If you will import from Oracle 11g to version 10g then you have to addthe parameter "version=10" to the parameter file above
BR
Mohamed ELAzab
http://mohamedelazab.blogspot.com/ -
Placing Summary column in master data block
I have a master/detail datablock form. i want to show the sum of "amount" field that is present in detail datablock and this summar field must be placed in master data block but it does not compile the form and shows following error.
FRM-30377: Summary item must reside in single-record block or in same block as summarized item.
Item: S
Block: PBL_PAYMENT_MASTER
FRM-30085: Unable to adjust form for output.
it works only by putting it in the same detail block with "Query All Records" to YES.
But I want to place this summary column in master data block but then it is not working.
How we can solve this problem.Hi,
In this case:
-- i put my summary column in the master data block with :Query_All_RECORDS set to yes
--but Physically it is placed on detailed block on the canvas
and it Works with this trick.
Regards,
Abdetu. -
Hi all, I have a pair of statements connected by a UNION, where I need to sort the final result according to columns not appearing in any column list:
SELECT REF(d) FROM DOCUMENT_TABLE d
WHERE d.header$.parentKey = ?
UNION
SELECT REF(d) FROM DOCUMENT_TABLE d, CROSS_TABLE k
WHERE k.doc = d.key$ AND k.folder = ?
ORDER BY d.header$.name
this fails saying that d.header$.name is an invalid identifier (ORA-904), like being out of scope.
Both union branches succeed when run alone (select + order by).
How can I sort by colums without having them to be returned ?
In all examples I found columns are also retrieved and referenced by either alias or by position.
Thanks.Hi,
In a UNION query, you can only ORDER BY columns in the SELECT clause.
You can do the UNION in a sub-query, then do the ORDER BY in the main query, where you can ORDER BY anything:
WITH union_results AS
SELECT REF (d) AS ref_d
, name
FROM DOCUMENT_TABLE d
WHERE d.header$.parentKey = ?
UNION
SELECT REF (d) AS ref_d
, name
FROM DOCUMENT_TABLE d
, CROSS_TABLE k
WHERE k.doc = d.key$
AND k.folder = ?
SELECT REF_D
FROM union_results
ORDER BY name
;Your front end may be able to hide specified columns, so you could do this without a sub-query.
For example, in SQL*Plus you can say:
COLUMN name NOPRINT
SELECT REF (d) AS ref_d
, name
FROM DOCUMENT_TABLE d
WHERE d.header$.parentKey = ?
UNION
SELECT REF (d) AS ref_d
, name
FROM DOCUMENT_TABLE d
, CROSS_TABLE k
WHERE k.doc = d.key$
AND k.folder = ?
ORDER BY name
;The result set actually contains two columns, but SQL*Plus will only display one. -
Typically, this sort of thing is easily achieved in Excel where you can calculate the values in an output column based on input values. I need to do this in Reports. I am using Reports 6i (Report Builder 6.0.8.27.0)
I have a relatively simple query where I am outputting values (Counts) and then I need to display the summation on the next line. Let me explain using an example:
ID Start Date End Date Column 1 Column 2
=============================================
1 01-JAN-2010 30-JUN-2010 120 0
2 01-JUL-2010 31-DEC-2010 200 120
3 01-JAN-2011 30-JUN-2011 115 320
4 01-JUL-2011 31-DEC-2012 300 435
5 01-JAN-2013 30-JUN-2013 100 735
As you can see that Column 2 is derived by adding the previous values in Column 1 and outputting it on the next line.
So, for ID = 4, Column 2 = 120 + 200 + 115 = 435 and ID = 5, Column 2 = 120 + 200 + 115 + 300 = 735.
When I use summary columns, I don't get the desired result.
I could technically create a Formula column and have a place holder column and re-query the results but I was hoping to avoid another SQL when the data has already been fetched. Any ideas or pointers would be greatly appreciated!
Thankshi,
i think i can satisfy u
download the rdf (6i)
https://www.zeta-uploader.com/1236837069
This URL is valid until Tuesday, June 25, 2013
thanks
mostafiz mitul -
Oracle rdf summary column is not working as expection
hi
I have Requirement to bring as below Format
emplo name
project name
project nnumber
cp_1
cp-2
...cp_25
mark
abc
123
20
30
10
mark
dfc
234
25
35
15
mark
45
65
25
for that i have created the Rdf and rtf
In Oracle Report
One group
data model query
group name G_project_number
and i create formula column to give the values in the cp_1 to cp_25
My RTF format
Employee name
project name
project number
cp_1
cp_2
..cp_25
<for each : g_project_number><?employee nmae?>
<?project name?>
<project number ?>
<?cf_1?>
<?cf_2?>
...<?cf_25?>
<?employeename?>
<?cs_1?>
<?cs_2?>
..<?cs_25?><end for -each>
summary columns in the same data model group
now report is showing as accumalate value for the columns
employee name
project name
project number
cp_1
cp-2
...cp25
mark
abc
123
20
30
10
mark
20
30
10
mark
dfc
234
25
35
15
mark
45
65
25
and my data model
one group
all info in that
Please guide me how to take forward this to achieve
Thanks in advancesPlease check the below link just to make sure all steps are taken care.
http://oraclemaniac.com/2012/08/15/how-to-add-a-descriptive-flexfield-dff-in-a-custom-oracle-apps-form/ -
Rows to columns/Transpose the records Query and Display output
hi ,
can anyone help me query this and transpose it to this format?
i am still a beginner in sql.
thanks for help!
Rows to columns/Transpose the records Query and Display output
id startdate endate
1111 1/2/2001 11/3/2001
1111 2/5/2002 4/3/2002
1111 2/6/2000 2/5/2001
3333 5/2/2003 11/3/2003
3333 6/2/2003 12/3/2003
3333 2/6/2005 2/5/2005
desired output
id startdate1 endate1 startdate2 endate2 startdate3 endate3
1111 1/2/2001 11/3/2001 2/5/2002 4/3/2002 2/6/2000 2/5/2001
3333 5/2/2003 11/3/2003 6/2/2003 12/3/2003 2/6/2005 2/5/2005Have you only 3 dates for each id ?
So, try :
SQL> l
1 with tbl as
2 (select 1111 as id, to_date('01/02/2001','DD/MM/YYYY') startdate, to_date('11/03/2001','DD/MM/YYYY') enddate from dual union all
3 select 1111 as id, to_date('02/05/2002','DD/MM/YYYY') startdate, to_date('04/03/2002','DD/MM/YYYY') enddate from dual union all
4 select 1111 as id, to_date('02/06/2000','DD/MM/YYYY') startdate, to_date('02/05/2001','DD/MM/YYYY') enddate from dual union all
5 select 3333 as id, to_date('05/02/2003','DD/MM/YYYY') startdate, to_date('11/03/2003','DD/MM/YYYY') enddate from dual union all
6 select 3333 as id, to_date('06/02/2003','DD/MM/YYYY') startdate, to_date('12/03/2003','DD/MM/YYYY') enddate from dual union all
7 select 3333 as id, to_date('02/06/2005','DD/MM/YYYY') startdate, to_date('02/05/2005','DD/MM/YYYY') enddate from dual )
8 select id, max(decode(dr,1,startdate)) start1,
9 max(decode(dr,1,enddate)) end1,
10 max(decode(dr,2,startdate)) start2,
11 max(decode(dr,2,enddate)) end2,
12 max(decode(dr,3,startdate)) start3,
13 max(decode(dr,3,enddate)) end3
14 from (select id, startdate,enddate, dense_rank() over (partition by id order by startdate) dr from tbl)
15* group by id
SQL> /
ID START1 END1 START2 END2 START3 END3
1111 02/06/00 02/05/01 01/02/01 11/03/01 02/05/02 04/03/02
3333 05/02/03 11/03/03 06/02/03 12/03/03 02/06/05 02/05/05
SQL> HTH,
Nicolas. -
Change of source of Summary columns in RDF
Hello Everybody.
For the existing query column in RDF, which is used by one of the summary column as source.
If the query is getting changed as per the bussiness requirement, the source of the Summary column is changing to NULL.
Is there any way not to allow this change in RDF. Because lot of query modifications are done.And it consumes lot of time to change every source of the Summary columns being used.
Appreciate your help.
Thanks.Yogesh,
Does both the clients allow development in the server? Generally it should not be the case.
Does the client still exists in the server?
Here is a thread with replies for such an error message.
Re: regarding Client change for transport request
Check it,it may give you some lead.
K.Kiran. -
Summary columns in portal forms
i have a master-detail form and i need to sum(one of detail columns) and display the result in the master block.
has anyone any ideas on how to have a summary column in master in oracle portal ?
has anyone done this before ?
thanx
nullNot exactly what you want, but I have managed to put a summary table at the end of the detail block. This gives a total for all detsail records for the current master, not just those displayed.
Add a pl/sql block to the 'after displaying the page' section of the Additional PL/SQL code tab to run the code you need. THis pl/sql block will include the p_session.get_value function to get the identifier of the master record, a query on the detail table and the HTML code to display the results.
Another method might be to create a view to contain the summary details you need for each master record, and base the master block on this view.
Maybe you are looking for
-
Multiple Locations in Receiver File channel
Hi Experts, Can i give multiple locations to pick the file in receiver filec hanel depending on some condition. Thanks Ajay Garg
-
RE-Importing into Lightroom 3 from external drive---simple?
This is isn't as simple as it sounds. My hard drive started to fail, but I replaced it with a new one (I still have access to all of the data on the old hard drive). I used to use Photoshop Elements to organize my photos, but moved to LR2 several y
-
How much RAM, and what CPU do I need for Adobe InDesign ?
hi guys.... each series of Adobe products, I notice that the products get heavy and more heavy than the previous one, so let's talk about the CS2 of Adobe products ( where I first dealt with Photoshop and InDesign) they were good as for the system re
-
I f i use Adapter specific identifiers in receiver file adapter... as pet this http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm but if i want the file schema format as abc_xxxx.dat wher xxxx is idoc number..
-
After editing a fillable PDF, how do I make it not editable?
after editing a fillable PDF, how do I make it not editable?