Query with totals in last row
Hi All,
My query below works well for my purpose of showing open deliveries and info, however It does not display drill down arrows because I am using UNION operator.
For Browse does not work.
Could anyone help/advise me on any other options or methods to achieve a similar result with drill downs?
SELECT T0.[DocNum], T0.[DocDate], T0.[DocTotal], T0.[GrosProfit],
((T0.[GrosProfit] / (T0.[DocTotal] - T0.[GrosProfit]))*100) As 'Profit %', T1.[CardCode], T1.[CardName],
T0.[NumAtCard], T2.[GroupName], T1.[Phone1], T1.[CntctPrsn]
FROM ODLN T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCRG T2 ON
T1.GroupCode = T2.GroupCode WHERE T0.[DocStatus] ='O'
UNION
SELECT NULL, NULL, SUM(T0.[DocTotal]), SUM(T0.[GrosProfit]), NULL, NULL, NULL, NULL, NULL, NULL, NULL
FROM ODLN T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCRG T2 ON
T1.GroupCode = T2.GroupCode WHERE T0.[DocStatus] ='O'
ORDER by T0.[DocNum] desc
Many thanks,
John
Hi,
you want Link Button to masters data or to particular column?
Regards,
Bhavank
Similar Messages
-
Query with XMLTABLE returns null rows
Hello all,
I'm trying a query with XMLTABLE, but even thought the number of returned rows is correct, the row content is (null).
DB version is: 10.2.0.4.0
Here is my query;
SELECT s.DESCRIPTION
FROM EXECUTIONPLAN p,
XMLTABLE
('//executionPlan/executionPlanItems/summary'
PASSING p.DATA
COLUMNS
DESCRIPTION VARCHAR(250) PATH '/taskId'
) s
WHERE
trunc(extractValue(data, '/executionPlan/executionPlanHeader/statusChanged')) = to_date('2010-03-05','YYYY-MM-DD');Sorry the XML content is quite big -50k lines at average- so can't post the whole XML, but to give an idea;
/executionPlan
/executionPlan
/executionPlanHeader
/statusChanged
/x
/y
/executionPlanItems
/summary
/taskId
/summary
/summary
...The result looks like;
1 (null)
2 (null)
3 (null)
4 (null)
...Suggestions are very much appreciated :)
CheersHi guys,
Cracked it at last. It seems the column definition part does not like the forward slash in front of it. The following works;
SELECT s.DESCRIPTION
FROM EXECUTIONPLAN p,
XMLTABLE
( XmlNamespaces(DEFAULT 'http://www.staffware.com/frameworks/gen/valueobjects'),
'/executionPlan/executionPlanItems/summary'
PASSING p.DATA
COLUMNS
DESCRIPTION VARCHAR(250) PATH 'taskId'
) s
WHERE
trunc(extractValue(p.data, '/executionPlan/executionPlanHeader/statusChanged'
, 'xmlns="http://www.staffware.com/frameworks/gen/valueobjects"')) = to_date('2010-03-05','YYYY-MM-DD');I'm not sure if this is the way it is intended since it seems a bit weird to me and is not in line with the docs - or at least my understanding of them.
Thanks for taking the time to help out. Now on to coding :) -
BEx query with keyfigure rank in row, chars and other keyfigures in columns
Hi All,
I have a BEx query with Plant and Region in rows and two keyfigures(% and rank calculation) in the column. Now my requirement is to display rank in the first column, plant and % cal. in the next columns in query output.
Query ouput should look like :
rank plant %
1 XYZ 63.00
2 ABC 76.94 and soon.
Is any way possible to achieve this and if yes can anyone explain in detail with steps, I apprecaite your help with points.
Thanks
Eric.Hi Jerome,
Thanks for quick response, is there any alternate way like customer exits or etc. This is my requirement and I need to provide the users the solution. I appreciate your valuable time.
Regards
Eric -
Spooling the output of a Query with out displaying the rows
Hello All,
Is it possible to spool the output of
a query/dbms_output.put_line with out displaying
the Query output on the console.
In my case,list of rows in the output is huge, I want
to eliminate displaying the output of query
so that spooling will complete faster.
Thanks in advance.
-SriniYou can do:
SET TERMOUT OFFIn your script before doing the spool command.
You will have to write your query as a .SQL script and run it from SQL*Plus in order for it to work the way you expect.
sqlplus -s username/password @query_script.SQL -
Using pre-query with 2 characteristics in rows?
Hi @all,
I need your help regarding the following problem:
There are multiple conditions in one query, I'd like to do in a certain sequence.
Because these multiple conditions in BEx where processed as "AND", for example
companies must be part of the Top x and an key-figure of these have to be more than y.
As a result, we have the top x companies reduced by these companies that doesn't match the key-figure condition. So there were less than x companies.
That's why we decided to use pre-queries. Because the key-figure is a ratio of the company on a higher level that is "restricted" by a condition, we need two characteristics in rows. That seems to cause some strange results in the main query wherein not all companies where submitted.
Does anyone know some workaround or any approach for this problem? Please let me know every idea.
Or do you know another way to set a certain sequence of conditions?
Many thanks for your help.
TobiasI've found a hint that this can't be done by using replacement path variables. Instead we used several pre-queries.
-
Column chart from Bex query with 2 characteristics in rows and column
Hi,
We're trying to represent the following column chart in Dashboard Design:
Material/Month
January
February
March
Material 1
100
200
300
Material 2
400
500
600
Material 3
700
800
900
The BEX query has:
Result objects: Material, Month/year; amount
The problem is when i paste the Material dimension in the Excel, i'm getting the following result:
Material/Month
January
February
March
Material 1
100
200
300
Material 1
400
500
600
Material 1
700
800
900
So, when i display the column chart, the material tag is incorrect:
as the image attached shows.Hey Flora,
Happy to hear that its working now.
Answering your question, again its upto the connection and report format you are using. Based on your question i hope you your report output should be like this.
You cannot map to two labels for the series, again this report format is possible only in cross tab through Webi. I would suggest you to concatenate the material and month in a dimension in webi like below.
I have done the concatenation in excel level, i would suggest you to do that in webi. Try to reduce the formula as much in excel.
or
If you are using Query browser connection, then i would suggest you to create a separate report which will display the actual vs plan material wise, here you need to pass the material as a prompt.
Hope this helps in clear, please revert me for any clarification. -
How to write a query to get the total as a last row
Hi,
I need to get something like this ....
|TEAM LEADER| TEAM | OCT TRN | EMPS| YTD% |
|_____________|__________|__________|______|_______|
| JOHN | JD Team | 12 | 12 | 100 |
|_____________|__________|__________|______|_______|
| Total | | 12 | 12 | 100 |
|_____________|__________|__________|______|_______|
I have to get the last row as total adding the number columns ...
Thanks in advance ...Take a look at the GROUP BY ROLLUP feature:
create table t1
(team_name varchar2(30)
,wins number
,losses number
insert into t1 values ('Hornets',3,1);
insert into t1 values ('Panthers',4,0);
insert into t1 values ('Wolves',2,2);
insert into t1 values ('Badgers',0,4);
insert into t1 values ('Hornets',1,3);
commit;
select decode(team_name,
NULL,'TOTAL',
team_name) team_name, sum(wins), sum(losses)
from t1
group by rollup(team_name);
TEAM_NAME SUM(WINS) SUM(LOSSES)
Badgers 0 4
Hornets 4 4
Panthers 4 0
Wolves 2 2
TOTAL 10 10 -
DataGrid - Query´s Last Row as Footer
Hi!
I have a query like:
SELECT [User], 'Qtd' = Count(DISTINCT [OrderId])
FROM [Jobs]
GROUP BY [User]
UNION
SELECT 'Total', 'Qtd' = Count(DISTINCT [OrderId])
FROM [Jobs];
And I´m displaying this query result in a DataGrid object in an ASPX page.
I´d like to set the last row of the query as a footer with a specific formatting. How do I set the last row of my query as a footer record at the DataGrid?
Thanks,
Molina.Hello,
Please ask your question over in the ASPNET forum
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
I'm trying to query from one table (call it Table1) a batch of rows in another table (Table2) using VLOOKUP on a date specified in the first table (Table1). My problem is it's returning the last incident in Table2 of the requested date instead of the first incident. This really breaks the OFFSET scheme I'd like to use to collect the rest of the items for that date. Is there some way to compel VLOOKUP to return the first row of query results, not the last?
NOTE: I see I've asked this before, but forgot to go back and look at responses given. It's been a while and I've limped along until now with the way things were. I'm actually trying to delete this questions, so if you see it, ignore it. I suppose if someone can tell me real quick how to delete a stupid question, that might be helpful.you cannot delete a post yourself. You can flag the post an request a moderator remove.
-
Needs help to retrive the last row in a select query without using rownum
Hi ,
i need to retrive the last row from the select sub query without using rownum.
is there any other way to retrive the last row other than the below query.
is that the ROWNUM=1 will always retrive the 1 row of the select query ?
select from*
*(select ename from employee where dept_id=5 order by desc) where rownum=1;*
Please advise.
thanks for your help advance,
regards,
Senthur957595 wrote:
Actually my problem is ithat while selecting the parents hiearchy of the child data using
CONNECT BY PRIOIR query
I need the immediate parent of my child data.
For example my connect BY query returns
AAA --- ROOT
BBB --PARENT -2
CCC --PARENT-1
DDD IS my input child to the connect by query
Immediate parent of my child data "DDD" ---> CCC(parent -1)
i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
So confusing with using this rownum in my query.
Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
you can select the PRIOR values to get the parent details if you want...
SQL> ed
Wrote file afiedt.buf
1 select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
2 from emp
3 connect by mgr = prior empno
4* start with mgr is null
SQL> /
EMPNO ENAME MGR
7839 KING
7566 JONES 7839
7788 SCOTT 7566
7876 ADAMS 7788
7902 FORD 7566
7369 SMITH 7902
7698 BLAKE 7839
7499 ALLEN 7698
7521 WARD 7698
7654 MARTIN 7698
7844 TURNER 7698
7900 JAMES 7698
7782 CLARK 7839
7934 MILLER 7782
14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data) -
Query with a condition - Overall results row displays incorrect value
Hi All,
I have a bw query with top 40 conditions. However, The Overall Result Row Figures Do Not Equal The Sum of the Column Rows.
Although the top condition is activated, the overall result still displays the overall result of the whole report.
I have 3 columns in the report
Selected Period
Prior Period and
Variance
The formula for variance is (Selected Period/Prior Period)-1.
Does anyone have an idea to fix this?
Thank you so much in advance.
Have a great day!Hi Gaurav,
Thank you so much for your reply, however this does not solve fully the issue.
Changing the properties to "Summation" will indeed provide me with the correct sum for the "selected period" and "Prior Period." However what I need in the Overall Result Row for the "Variance" column is not the total but instead the value when the total of Selected Period is divided by Prior Period then minus 1.
Overall Variance = (Overall Selected Period/Overall Prior Period)-1
Do you know a way to make this possible.
Thank you so much. -
Sum of Table column contents into a last row with respect to column
In a WebDynpro for java application,
Need to sum up all the table with respect to column, at the last Row of the table with respect to column.
Only one table should be present for contents as well for the total.
Please help me.
Edited by: devender vadithyabadabath on Jan 12, 2008 11:54 AMHi,
you must add e last element at the end of you Nodeelements.
I<yourNode>Node node1 = wdContext.node<;yourNode>;
I<yourNode>Element element = node1.create<;yourNode>element.;
Iterate over the your node element to build your sum of each and than add this sum to the last row of your table.
element.set<;yourAttribute>(sum);
node1.addElement(element);
I hope this helps
regards
Gunter -
Not getting total of results row in bex query
Hi Experts,
In Bex I have created new formula variable which is the Percentage of On time delivery for a particular vendor. The problem is when I use calendar year and vendor in rows and CK in columns and execute the query, I am not getting the the total value of particular vendor percentage for the year. Instead I am getting the value of 'X'.
I tried to change the calculation result as "summation" but still I am facing the same issue.. If need more explanation i can give screenshots.
Please help.
Regards,
MathivananHi Anshu,
Thanks for your valuable reply. Here is the screenshots
The formula variable I have created is based on some CK's. When i run query for all vendors I am getting the result percentage. But when I run the query with calendar year I am getting result as below
The OTD Percentage is not the total % of the year 2010 for the particular supplier(vendor). -
Hello everyone,
I was trying looping over a query which has to be executed
only when the last row of a previous loop has been reached. The
question is: I have nested loops, I am able to print the values
based on two loops:
for example: <cfloop query="advisor">
<cfloop students>
</cfloop>
</cfloop>
I am able to get student values for a particular advisor and
print the values for different advisor and students. I am trying to
include another loop like grades within advisor loop which should
be executed at the end of students list for that particular
advisor. What I am doingg right now is displaying the values in a
table format.
<table>
<tr>Advisor</tr>
<tr>Student1<tr>
<tr>Student2</tr>
<tr>Grades</tr>
How is possible to know when I would reach the end of the
student loop for an advisor and then loop the grades for the same
advisor before proceeding to another advisor?
Any suggestions would be great.
Thanks.The group attribute of cfoutput would be a lot more
efficient. Useage is described in the cfml reference manual. If you
don't have one, the internet does.
It would also be more efficient to get all your data with a
single query. -
Query with Top N Condition (Result Row)
Hi,
I made a query with an active top n condition. The query has 2 Keyfigures and 1 formula
Gross-sales acutal | Gross-sales previous year | Previous Year %
So that to result line is correct, I had to say "Calculate result as summation" for the keyfigures
gross sales actual and gross sales previous year. That works.
I have the problem with my formula. the formular for previous year % is defined as follows:
gross sales actual %A gross sales previous year
Example Top 3 Customer
gross sales actual gross sales prev. year prev. year %
Cust 1 100 80 125 %
Cust 2 90 45 200 %
Cust 3 80 60 133 %
Result 270 185 142.8 % ( 350 * 100 / 245 )
The result of 142 % is the correct result without the condition top 3. with the top 3 condition
the result should be 270 * 100 / 185 = 145.9 %
Additional customer without top 3 condition
Cust 4 50 40 125 %
Cust 5 30 20 150 %
It shows the correct result for each single line. The result in the result row is wrong. it is calculated
without taking the active condition. the formular calculates
with the total gross sales actual and the total of gross sales prev. year.
is there any solution the achieve the correct % in the result row?
thanks for your help.
PascalPascal,this is a known behavior with conditions.When you apply condition it just hide the extra rows and it does not impact the result row.So your result row actually shows the value irrespective of the condition you apply.
Now with the help of local functions like calculate result as summation you can show the correct sum after applying the condition but when you try to use that result in some calculation then it takes the original value thereby discarding the calculated value.
Same is happening in your case as well.Its taking the original value i.e 350 and not the calculated sum after condition i.e 270.
Hope this helps.
Regards,
AL
Maybe you are looking for
-
Unable to find Oracle OCI libraries on Centos 6.3
Hello, I am having an issue with configuring an application(Zabbix) to use OCI on clean image of CentOS 6.3. checking for Oracle OCI headers in /usr/include/oracle/11.1/client/... yes checking if Oracle OCI version is >= 10.0... yes checking for Orac
-
Looping is very slow on large data set
Hi All, I need suggestion in optimizing the below looping scenario . Sample data in the table , For easy understanding I kept only 4 columns actual source has 56 columns Input : #Final RwNum JobSource RuleName PackageType 1 Presubmission GameRating
-
Dear Experts, I have a report which is displaying 2 types of reports( based on the selection of radio button in selection screen assembly report, production report) both are having same fields and different fieldcatalogs Now, My requirement i
-
Selecting pictures that are not in albums
How do I select the pictures that are in my library, however are part of any album in the same library?
-
SMP3.0 Sizing Guide for Agentry Apps
Hi All, I'm looking for a sizing guide for Agentry Apps (Work Manager in particular) on SMP3.0. I only found the SMP2.3 sizing guide and the quicksizer has a SMP3.0 entry but only seems to refer to Mobilizer and Odata. Has anyone SMP3.0 Agentry sizin