Sum columns in different groups
Hi Alll,
I have created 4 queries. In all quries rmng column is there. It is printed like
group1 group2 group3 group4
rmng1 rmng2 rmng3 rmng4
3 2 4 5
6 7 10 11
I need to calculate rmng columns and put it into tot rmng column like
group1 group2 group3 group4
rmng1 rmng2 rmng3 rmng4 totrmng(rmng1+rmng2+rmng3+rmng4)
3 2 4 5 14
6 7 10 11 34
How to do in reports? Can you please tell me the solution?
Thanks,
Ann
hi Ann,
Virtual Column:_
Try the below in your table,
Alter table <TabName> add (totrmng as (rmng1+rmng2+rmng3+rmng4));
and then just add the newly added column in your query to achieve the needs.
Regards,
Navin Kumar G
Similar Messages
-
Referencing different columns from different groups
Hi all,
I created a formula column in a group , say g1. This formula column references in a bind reference fashion one column from g1 and another column from another group , say g2. And when I run the report then there is an error because of the external reference from group g2. So how can I reference both the two columns because I must calculate something from both of the two columns !
Thank you very much indeed.Hi,
Here i'm facing similar problem.
I have a query Q1 which will get data in two columns p_plan, p_real. And I have another Q2 which will bring the data in two columns m_plan, m_real. Now i want to display the difference of (p_plan - m_plan) and (p_real - m_real).
Since these fields for which the diff should be calculated are present in two different groups, std error "below Frequency error is thrown.
Any advice pls -
Sum columns of different record count in joined tables
I have a problem with a query, please help.
I have two tables:
create table rec_a (key_code varchar(20),
TOT_AMT varchar(20),
INV_AMT varchar(20))
create table rec_B (key_code varchar(20),
INVOICE_AMT varchar(20),
PAID_AMT varchar(20))
insert into REC_A values (123123, 1168182.16, 1168182.16);
insert into REC_B values (123123, 205699.04,205699.04);
insert into REC_B values (123123,130912.78,130912.78);
insert into REC_B values (123123, 81622.87,81622.87);
insert into REC_B values (123123, 438032.43,438032.43);
insert into REC_B values (123123, 159936.17,159936.17);
insert into REC_B values (123123, 151978.87,151978.87);
table 1
KEY_CODE TOT_AMT INV_AMT
123123 1168182.16 1168182.16
table 2
KEY_CODE INVOICE_AMT PAID_AMT
123123 205699.04 205699.04
123123 130912.78 130912.78
123123 81622.87 81622.87
123123 438032.43 438032.43
123123 159936.17 159936.17
123123 151978.87 151978.87
I wrote a query to sum up all the fields (tot_amt,inv_amt,invoice_Amt,paid_amt)
SELECT B.key_code,sum(A.invoice_amt),sum(a.paid_amt),SUM(b.tot_Amt),SUM(b.inv_amt) FROM rec_a B, rec_b A WHERE A.KEY_CODE=B.KEY_CODE AND B.KEY_CODE in ('123123')
group by B.key_codeI got this:
KEY_CODE SUM(A.INVOICE_AMT) SUM(A.PAID_AMT) SUM(B.TOT_AMT) SUM(B.INV_AMT)
123123 1168182.16 1168182.16 7009092.96 7009092.96
But I expected this
KEY_CODE SUM(A.INVOICE_AMT) SUM(A.PAID_AMT) SUM(B.TOT_AMT) SUM(B.INV_AMT)
123123 1168182.16 1168182.16 1168182.16 1168182.16
Can anyone help me here?
Thanks
Edited by: 1003064 on Apr 29, 2013 3:19 AMHi,
welcome to the forum.
Please read SQL and PL/SQL FAQ
Particularly post CREATE TABLE and INSERT statement, describe the logic and post your expected output.
When you put some code and/or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
It's also considered a good practice to mark questions as answered when the answers are satisfying your question or provide additional details.
How does rec_a and rec_b tables relates to table1 and table2?
It seems that yours is a very simple error. When you join 2 tables all the common rows get repeated.
So without grouping your table will have something like this:table 1 table 2
KEY_CODE TOT_AMT INV_AMT KEY_CODE INVOICE_AMT PAID_AMT
123123 1168182.16 1168182.16 123123 205699.04 205699.04
123123 1168182.16 1168182.16 123123 130912.78 130912.78
123123 1168182.16 1168182.16 123123 81622.87 81622.87
123123 1168182.16 1168182.16 123123 438032.43 438032.43
123123 1168182.16 1168182.16 123123 159936.17 159936.17
123123 1168182.16 1168182.16 123123 151978.87 151978.87
Now sum up all the columns and you will understand why you get that result.
Regards.
Al
Regards.
Al
Edited by: Alberto Faenza on Apr 29, 2013 12:17 PM -
OBIEE Group By on 2 facts and concatenated columns from different dimensions
Hi
I have a different kind of problem involving 2 fact tables with different dimensional attributes.
Fact 1 has Dim Attributes ( Cust,Facility )
Measure - Gross Amount
Fact2 has Dim attributes (Cust,Facility and Risk Group )
Measure : Exposure Amount
Since we have 2 facts with different dimensions,
to exclude the 'Risk Group' dimension column from the group by for the Fact1,
we set the 'Gross Amount' measure to total level (Risk Group Dimension ) in contents tab.
So the values from both the fact tables appears in the same report correctly.
But in the same report we have another requirement where the rating column from the customer dimension has to be concatenated with the ratings column in the facility dimension.
We have to concatenate customer.rating with the facility.rating and display it in the report.
when we just pull the individual columns from the dimensions into the report it works fine.
But when we try to concatenate the 2 columns and show it in the report,
the concatenated column does not appear in the select or the group by in the SQL Fact2.( Generated by OBIEE )
The other fact1 has the concatenated column in the select as well as the group by clause ( Generated by OBIEE )
As a result the report shows the concatenated values only for the results from the Fact1. But the results from Fact2 does not have the concatenated column values.
The report should look like the below:
Custor.Name, Customer.Id, Facility.Name, Facility.Id, Customer.Rating/Facility.Rating, Risk Group, Gross Amount, Exposure Amount
=========== ========= =========== ========= ======================== ========= =========== ===============
JPMC 123 GROSS 123 08/10 LNL 45,000 25,000
CLAIRE 456 NET 456 07/10 RNK 50,000 30,000
Thanks,
ChandraAs suggested you really want to move your none-aggregated fact attributes to a logical dimension (using the same physical table as the logical fact). Map this in the BMM layer as a snowflake, Place a hierarchy on this dimension with (at minimum) Total -> Detail levels, then on the other fact table you want to include in the report, set the content level on your other fact measures to the 'Total' level for your new logical Dim and it will allow them to be present in the same report.
-
How to make sum of a column in Datatable grouping?
I have done Datatable grouping and Now I want to sum 2 columns for individual groups.
How should I do?
In the Second Image The grouping is shown.In the second Image.
In the first image I have expanded that group and in that I want to do sum for contribution and distribution column.
How should I achieve It?
Thanks in Advance.Hi,
We can create a Calculated column to achieve it. The column settings as below:
Best Regards
Dennis Guo
TechNet Community Support -
Post Author: tadj188#
CA Forum: Formula
Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
Background:
1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using subreports. A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report with their respective detail lines). I had multiple subreports and each subreport became one union.
Created and tested, already:
1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
Issue:
1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
Other Ideas Appreciated:
1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
Thank you.
Tadjexport all image of each page try like this
var myDoc = app.activeDocument;
var myFolder = myDoc.filePath;
var myImage = myDoc.allGraphics;
for (var i=0; myImage.length>i; i++){
app.select(myImage[i]);
var MyImageNmae = myImage[i].itemLink.name;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
app.jpegExportPreferences.exportResolution = 300;
app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
alert(myImage[i].itemLink.name) -
How to use single column in a group by clause
hi frs
i hve used sum function in a sql how to use a single column in a query.
for ex
select sum(sal),ename,job,deptno,empno from emp
group by deptnowhether its possible to use single column in a group by class.
i want like this because in my custom report i need it. Report query has more than 30 column so its not possible to use 30 columns in a group by.
pls help.
Thanks
RajeshMaybe something like this -
Select ename, job, deptno, empno, sal, col1, col2, col3, col4 ......, coln
From
Select SUM(sal) sal, deptno deptno_i
From Emp
Group By deptno
,Emp
Where deptno = deptno_i
Shailender Mehta -
More than 1 column in the group by clause
DB Version:10gR2
I understand the basics of GROUP BY clause. I have a question on why we have on more than 1 columns in GROUP BY clause.
In the below example, the course name by itself does not make up a group. A Course name plus its BeginDate make up a group. This is the whole point of having more than 1 columns in the GROUP by clause. Right?
SQL> select r.course, r.begindate , count(r.attendee) as attendees
3 from registrations r
4 group by r.course, r.begindate
5 order by course
6 /
COURSE BEGINDATE ATTENDEES
JAVA 12/13/1999 5
JAVA 2/1/2000 3
OAU 8/10/1999 3
OAU 9/27/2000 1
PLS 9/11/2000 3
SQL 4/12/1999 4
SQL 10/4/1999 3
SQL 12/13/1999 2
XML 2/3/2000 2ExpansiveMind wrote:
Thanks Dmorgan. I am just learning the basics of GROUP BY clause. I have noticed that all Non-aggregate columns in SELECT list have to be present in the GROUP BY clause. I thought it was a "syntactical requirement". Now, i realise that these columns are present in the GROUP BY clause because only a combination of columns make up a group.Well, it is a bit of both actually. It is a syntactic requirement that all non-aggregated columns in the select list must appear in the group by clause. However, the non-aggregated columns in the select list is what defines your group. Your two examples define two different groups, and would answer two different questions.
John -
Join columns of different data types
Can i join two columns of different data types in a single statement. Is there any cast or convert statement
SELECT B~PARTNER AS RESP_GROUP
FROM BUT000 AS B
INNER JOIN CRMV_LINKPARTNER AS C ON BPARTNER_GUID = CPARTNER_NO.
Here PARTNER_GUID is Raw 16 and PARTNER_NO is Char 32, the query is not returning any rows.
Thanks
Akila.RHi!
Basically we can say, you can't join them, but you might try this way:
SELECT B~PARTNER AS RESP_GROUP
FROM BUT000 AS B
INNER JOIN CRMV_LINKPARTNER AS C ON BPARTNER_GUID = CPARTNER_NO(16). "add
(16)
Or an other version
C~PARTNER_NO+16(16) "depends on, where is the real number stored
Regards
Tamá -
Amount of a sum in a different currency
looking for function or other way to check the amount of a sum in a different currency for a certain exchange type according the currencies and exchange rate definition.
ThanksHi,
You can use CONVERT_TO_LOCAL_CURRENCY function.
Regards,
Eli -
How to get the last vaue of an amount column in the group above
Hi All,
I have a requirement
In my report there are 3 gruops in data model.
1.accout flex field
2.balance
3. journal entries
3. JE contans debit,credit and the running total.
My requirement is to print the final total in the frame above the repeating frame.
Please help me in this case as to how can i achieve this requirement?
Thanks
Jana.If you have any column in JE group, you can not print that directly in 'balance' group or between repeating frames of the JE and balance. It has to be in JE or any group below JE.
You can try what i suggested earlier. It would give you the last total of the journal. And you can place the field near to the repeating frame of JE.
Hope this helps. -
One Key FIgure in more than one column with different restrictions
Hi,
I am using a key figure in more than one column with different restrictions, but restriction in one column is affecting the result in other column. What shall i do to make it independent from one another??Hi Pravender Chauhan,
If you want in Single column different value for different Rows based on same Key Figure, you can create Structure where you can define different logic for each row but using same key figure.
If you want to use different Key figures then you should have to Restricted Key Figure and for any calculation you can use calculated Key figure.
Assign points if Useful.
Regards,
Rajdeep. -
How to use a USER_DATASTORE to index multiple columns in different tables
I would appreciate if somebody can give an example or point to links with examples on how to use USER_DATASTORE on multiple columns in different tables. THe Oracle Text documentation only shows multiple columns in the same table.
Thanks in advance.I am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.
-
Why does my iTunes show apps in two different groups?
When I open my iTunes 10 and look at the Apps tab, it shows my iPhone and iPad apps distributed amongst two different groups: iPhone, iPod Touch and iPad Apps and iPhone and iPod Touch apps. I don't really understand this as I don't have a iPad. An I only loaded a few apps to my iPod Touch years ago. Seems to me that the Listing should be showing apps sorted by the "Authorized Devices" to which they have been installed.
Another complication is that I have two Apple Store accounts...my US account from when I bought my first iPod Touch while living in the US and then a Thai account since I am living in Thailand and it makes payment easier. Isn't there a way to see the apps loaded into my Library sorted by Apple Store account??
Apple software is becoming more and more like the Microsoft products we all love to hate. Sadly, ease of use for the user is out the door. It's why I continue to use iTunes 10 and OS 10.6.8...stable and I know what I get and don't get already :-?
Thanks for the feedback.You got it right. Thank you.
-
My contacts on my iPhone are organized in different groups. I have downloaded a trade show app which gives infos on the exhibitors of the show. It offers to create new contacts from these info. Is there any way to save these new contacts in a specified group instead of putting them into the contacts root, where they are mixed with all the old ones? By the way, can we create a new contacts group directly from the IPhone, without having to go through the sync process with the PC?
Thanks a lot in advanceSorry, I forgot to bookmark the thread where the app was mentioned, but searching for "group" or "contacts" should bring a few results in the AppStore.
Maybe you are looking for
-
Photoshop Elements 12 does not install on Win 8.1 64bit
Hi! My system: Windows 8.1 64 bit with all patches, 32GB Ram and engough HD space. I downloaded PSE 12 32bit and Premiere Elements 12 64bit. Both won't install. Problems: Premiere: Installation fails when shared components should be installed. I spen
-
Rich Tree Table Drop duplicate Row Keys (from different Rich Tables)
Hello. My scenario looks like this: Two tables (lets say productTable, and taskTable) as drag sources. One Tree Table ( that should have the productTable items as a parent node, and the childNodes would be taskTable items), as a drop target.. In my t
-
What are the system requirements for Final Cut Pro 7?
I can't find the system requirements for Final Cut Pro 7, I can find the system requirements for X, but like I said not 7. I need to know the system requirements for Final Cut Pro 7, so I can buy the correct Macbook. Is there anyway I can find out th
-
An unknown error occured [13] when trying to restore iphone. Help!!
When trying to upgrade to the 2.0 upgrade my phone said I had to restore it to its original settings. Then I get an error stating " The iphone could not be restored. An unknown error occured [13]. Any suggestions?
-
Hi! I can't save my projects to the creative cloud... When I try to upload them to the cloud it shows a message of no connection. I'm connected, so I don't know what to do, can someone help me?! I'm using Photoshop touch for iPad iOS 7 thanks!!!