Help in the query for sub total.
hi friends.
i have a query display below output.
but i wanted to get sub total of each repeated records,.
Output is like below.
Segment
Units
Total items
CRE
CRE - MUMBAI
3
CTA
CTA - CHENNAI
13
CTA
CTA - DELHI
37
CTA
CTA - HYDERABAD
10
CTA
CTA - KOLKATTA
22
CTA
CTA - MUMBAI
110
Now i need to show like below. if you see the sub total in bold.
Segment
Units
Total items
CRE
CRE - MUMBAI
3
CRE
Sub Total
3
CTA
CTA - CHENNAI
13
CTA
CTA - DELHI
37
CTA
CTA - HYDERABAD
10
CTA
CTA - KOLKATTA
22
CTA
CTA - MUMBAI
110
CTA
Sub Total
192
please help.
with
the_data as
(select 'CRE' segment,'CRE - MUMBAI' units,3 total_items from dual union all
select 'CTA','CTA - CHENNAI',13 from dual union all
select 'CTA','CTA - DELHI',37 from dual union all
select 'CTA','CTA - HYDERABAD',10 from dual union all
select 'CTA','CTA - KOLKATTA',22 from dual union all
select 'CTA','CTA - MUMBAI',110 from dual
select segment,
case grouping_id(segment,units) when 0
then units
when 1
then 'Sub total'
else 'Grand total'
end units,
sum(total_items) total_items
from the_data
group by rollup(segment,units)
SEGMENT
UNITS
TOTAL_ITEMS
CRE
CRE - MUMBAI
3
CRE
Sub total
3
CTA
CTA - DELHI
37
CTA
CTA - MUMBAI
110
CTA
CTA - CHENNAI
13
CTA
CTA - KOLKATTA
22
CTA
CTA - HYDERABAD
10
CTA
Sub total
192
Grand total
195
Regards
Etbin
Similar Messages
-
A filter to be applied on the F4 help in the query
Hi
I have a requirement wherein the user wants a filter to be applied on the F4 help in the query (for e.g. company code) for a specific area(for this e.g. real estate). Can I do this as now it brings all the company codes that exist
Thanks
BhimaHi,
It might be done. If your specific area is a compounding attribute to company code then restrict your area and co_code by variables (user entry). After you enter area into variable, F4 help for a co_code variable will show only codes from the entered area.
Best regards,
Eugene -
Help needed in query for Materialized View
Hi,
I want to create a materialized view which has some precalcultaed values.
I have four dimension tables out of which one is a Time Dimension table with levels as Year->Quarter->Month.
The precalculations are the moving averages and cummulative values of Sales Amt on the dimension values over a period of 4 Months.
The dimension tables are Clients, Products, Channel, Time.
Fact Table is Sales_Fact which will have the sales amount for different members of the dimension.
Since my fact table is very huge, i want to create a materialized view where i could store the required calculated measures, here Moving Average of Sales Amt for each Client, Product, Channel dimensions over a period of 4 Months.
Can anybody help with writing the query for this..Any help in this regard will be appreciated..
Please give me suggestions for this..Check this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
Need helping in writing query for finding percentage of duration
Can any one please help in writing query for this.
The table is like this :-
ID Region Month Duration
I1 R1 Jan 80
I2 R2 Jan 70
I3 R1 Jan 70
I4 R3 Jan 40
I5 R1 Feb 80
I6 R2 Feb 30
I7 R3 Mar 100
I want to write a query to find
% of duration for each and every region against each and every month.
Please help in solving this query. I am in urgent need of this.
Thanks in advance.I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
Nicolas. -
I need help with the query
Here is what I need
For a particular comm record if there is no Salary record where comm:Date = Salary:Date, then
• Find maximum dated Salary record as of comm:Date.
• Clone this record and set Salary:Date = comm:Date
• Set Salary:rate = comm:rate
Like wise for a particular Salary record If there is no comm record where Salary:Date = comm:Date then
• Find maximum effective dated comm record as of Salary:Date
• Apply Rate 2 amount from this maximum effective dated record to Salary record i.e. Set Salary:rate = comm:rate
Example
Salary Table :
ID Sal_Date Rate Hours
1 07/01/2011 400.00 40
2 02/15/2011 200.00 40
3 01/01/2011 160.00 40
Sal_comm Table:
Sal_Date comm_Rate
1 07/01/2011 10.00
4 03/01/2011 7.50
3 01/01/2011 4.00
I need to merge comm_Rate column in Salary table, since there is no salary record as off 03/01/2011, I need to find the maximum dated salary record as of 03/01/2011
i.e. the record dated 02/15/2011. Now I need to clone that salary record, set the SAL_date as 03/01/2011 and update Rate2 amount. So the record set will be like:
Sal_Date:
id sal_Date Rate Hours comm_Rate
1 07/01/2011 400.00 40 10.00
4 03/01/2011 200.00 40 7.50
2 02/15/2011 200.00 40 4.00
3 01/01/2011 160.00 40 4.00So you need all used dates as the "driving" dataset. And you need the according data for each of these.
WITH salary_table as
(select 1 id,to_date('07/01/2011','MM/DD/YYYY')sal_date,400 rate,40 hours from dual union all
select 2 id,to_date('02/15/2011','MM/DD/YYYY')sal_date,200 rate,40 hours from dual union all
select 3 id,to_date('01/01/2011','MM/DD/YYYY')sal_date,160 rate,40 hours from dual),
sal_comm as
(select 1 id,to_date('07/01/2011','MM/DD/YYYY')sal_date,10 comm_Rate from dual union all
select 4 id,to_date('03/01/2011','MM/DD/YYYY')sal_date,7.5 comm_Rate from dual union all
select 3 id,to_date('01/01/2011','MM/DD/YYYY')sal_date,4 comm_Rate from dual)
select to_char(all_dates.sal_date,'MM/DD/YYYY') sal_date,sal.rate,sal.hours,com.comm_rate
from (select sal_date from salary_table
union
select sal_date from sal_comm) all_dates
inner join (select s1.*,lead(sal_date-1,1,to_date('31/12/9999','DD/MM/YYYY')) over (order by sal_date) next_sal_date
from salary_table s1) sal
on (all_dates.sal_date between sal.sal_date and sal.next_sal_date)
inner join (select s1.*,lead(sal_date-1,1,to_date('31/12/9999','DD/MM/YYYY')) over (order by sal_date) next_sal_date
from sal_comm s1) com
on (all_dates.sal_date between com.sal_date and com.next_sal_date)
order by all_dates.sal_date desc;
SAL_DATE RATE HOURS COMM_RATE
07/01/2011 400 40 10
03/01/2011 200 40 7.5
02/15/2011 200 40 4
01/01/2011 160 40 4
-
Need help writing a query for following scenario
Hi all, I need some help writing a query for the following case:
One Table : My_Table
Row Count: App 5000
Columns of Interest: AA and BB
Scenario: AA contains some names of which BB contains the corresponding ID. Some
names are appearing more than once with different IDs. For example,
AA BB
Dummy 10
Me 20
Me 30
Me 40
You 70
Me 50
Output needed: I need to write a query that will display only all the repeating names with their corresponding IDs excluding all other records.
I would appreciate any input. ThanksIs it possible to have a records with the same values for AA and BB? Are you interested in these rows or do you only care about rows with the same value of AA and different BB?
With a slight modification of a previous posting you can only select those rows that have distinct values of BB for the same value of AA
WITH t AS (
SELECT 'me' aa, 10 bb FROM dual
UNION ALL
SELECT 'me' aa, 20 bb FROM dual
UNION ALL
SELECT 'you' aa, 30 bb FROM dual
UNION ALL
SELECT 'you' aa, 30 bb FROM dual
SELECT DISTINCT aa, bb
FROM (SELECT aa, bb, COUNT(DISTINCT bb) OVER(PARTITION BY aa) cnt FROM t)
WHERE cnt > 1; -
Infoobject F4 help in the Query takes lot of time and hangs
Hi All,
I have 0Material in the query and the F4 help for selection takes lot of time and hangs after some time.
The 0Material has 2 million records the Infoobject properties for Bex are as below:
Selection:No selection restriction
Query Def. Filter Value Selection: Values in Master Data Table
Query Execution Filter Val.Selectn:Only Posted Values for Navigation
We tried to alter some of the Properties but we have the same issue.
Suggest other options that can be be looked into to get the F4 help in the Query .
Thanks,
Mikehi Mike,
check if helps
Note 817335 - Performance in F4 Help
Note 748623 - Input help (F4) has a very long runtime - recommendations
Note 581802 - Variable dialog boxes: performance of the F4 help
search oss note for f4 performance ...... -
What will be the query for the below stated problem..??
Dear Sir
I want that in Incoming payment after selecting a Customer when we right click and select payment means under checks tab the bank details of that customer should be there i.e. According to Bank Code its Branch and Account no be shown with the help of a query. If anyone knows the query for this please let me know...Hello jyotasna ,
Let me try explain
SAP Process :-
When you make incoming payment with Cheque or bank then this is not complete sale cycle.
Bank Offset Account Debit
Customer Account Credit
You should make deposit(Banking>Incoming Payment>Deposit) for which you have made incoming payment.and here we put all info for bank account
Bank Account Debit
Bank Offset account Credit
Why :-
Suppose your client said that he deposit your cheque in bank in this date but due same bake issue or cheque issue the same cheque deposited in next day.
In this senario if i made this entry in SAP then we need to modify it based on Bank Reconciliation Statement(BRS)
We also have bank reconciliation set for same
Is there any confusion ?
Thanks
Manvendra Singh Niranjan
Edited by: Manvendra Singh Niranjan on Jul 13, 2011 1:10 PM -
Need to install only the query for fi account receivables standard data ?
Hi all,
I need to insall only the query for the standard business content for fi_ar in bw 3.5 ?
i have selected the cube and then in grouping i have selected data flow afterwards only.
And i have selected the queries only. but the cube is selected again. Should i uncheck the cube and install only the queries and transport it?
Pls guide me on this!!
Thanks
PoojaHi,
If the required cube is already avaialble and continue with the existing design, you can uncheck the cube and install only queries. Check all the prerequisites before installing queries like used infoobjects, other targets if any.
Hope this helps,
Regards,
Rama Murthy. -
Hi Guys,
What is the query for Accounts Payable Trial Balance (APXTRBAL) in 11.5.10?
I have to write an AP Invoice Aging Report in Discoverer to show all unpaid invoices that have been transferred into GL... Business wants it to match one-to-one with the AP Trial Balance standard report...
Business wants to run the report for any date in a past...
The report has two parameters:
As Of Date - the same as As of Date for the AP Trial Report
Trial Balance Run Date - the date when Trial Balance was run...
Conditions are:
TRUNC(Invoice Date) <=TRUNC(NVL(TO_DATE(:As Of Date),SYSDATE))
TRUNC(NVL(Payment Date,'01-JAN-5000')) > TRUNC(NVL(TO_DATE(:As Of Date),SYSDATE))
TRUNC(Invoice Creation Date) <= TRUNC(NVL(TO_DATE(:Trial Balance Run Date),SYSDATE))
Distr Accounting Date <= TRUNC(NVL(TO_DATE(:As Of Date),SYSDATE))
NVL(Distr Creation Date,Invoice Creation Date) <= TRUNC(NVL(TO_DATE(:Trial Balance Run Date),SYSDATE))
Show_Flag = 'YES', where:
Show_Flag = CASE WHEN ( NVL(Cancelled Date,'01-JAN-1901') > NVL(:As Of Date,SYSDATE) AND NVL(Inv Amount Aud,0) = 0 ) THEN 'YES' ELSE ( CASE WHEN NVL(Inv Amount Aud,0) = 0 THEN 'NO' ELSE 'YES' END ) END
There is a difference between the logic of my report, and the logic of AP Trial Balance...
Could you please advise what I'm missing?
Thanks,
IanaWhat is the query for Accounts Payable Trial Balance (APXTRBAL) in 11.5.10? You can get the code by opening the report in Reports Builder and get the query.
Or, enable trace/debug as per (FAQ: Common Tracing Techniques within the Oracle Applications 11i/R12 [ID 296559.1]).
Thanks,
Hussein -
How to find out the link for the tables for sub contract PO
Dear All,
How to find out the link for the tables for sub contract PO, I am looking for the fields Material, Unit, Batch no., quantity.
Please provide the solution for the Table related to ABAP.
Thanks,
V.V.Hi,
Make use of the table EKKO, EKPO...
For subcontract please select the option in EKPO-PSTYP.
Regards
GK. -
Issue While executing the Query for Pagination using ROWNUM with like
Issue While executing the Query for Pagination using ROWNUM with like.
Database is Oracle11G.
Oracle Database Table contains 8-9 lakh records
1) SQL equal (=)
SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
WHERE A.REFERENCE = 'KMF22600920'
Execution Time:- 0.00869245 seconds
Returns 2 resultsets
2) SQL like (one %)
SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
WHERE A.REFERENCE = 'KMF22600920%'
Execution Time:- 0.01094301 seconds
Returns 2 resultsets
3) SQL like (two%)
SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
WHERE A.REFERENCE like '%KMF22600920%'
Execution Time:- 6.43989658 seconds
Returns 2 resultsets
In Pagination, we are using Modified version of SQL Query 3) with ROWNUM as mentioned below :-
4) SELECT * FROM (
SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
WHERE REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) WHERE RNUM > 0
Execution Time:- Infinite
ResultSets:- No as execution time is infinite
a) Instead of like if we use = in the above query it is returning the 2 resultsets (execution time 0.02699282 seconds)
b) Instead of two % in the above query, if use one example REFERENCE like 'KMF22600920%' it is returning the 2 resultsets (execution time 0.03313019 seconds)
Issue:- When using two % in like in the above query i.e. REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) , it is going to infinite.
Could you please let us know what is the issue with two % used in like and rownum
5) Modified version of Option1 query (move out the RNUM condition AND RNUM <= 20)
SELECT * FROM (
SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
WHERE REFERENCE like '%KMF22600920%' ) WHERE RNUM > 0 AND RNUM <= 20
Execution Time:- 7.41368914 seconds
Returns 2 resultsets
Is the above query is best optimized query which should be used for the Pagination or still can improve on this ?This would be easier to diagnose if there was an explain plan posted for the 'good' and 'bad' queries. Generally speaking using '%' on both sides precludes the use of any indexes.
-
Help on the parameters for function ENQUEUE_E_TABLE
Hi,
Does anyone has detailed help on the parameters for the function ENQUEUE_E_TABLE?
For example, what does the parameter _SCOPE? and how many keys can I specify in VARYKEY?
ThanksHi,
SCOPE is for - Control lock behavior when calling the update task.
ENQMODE - Lock mode
VARYKEY - Lock key for tables
TABNAME - Table Name
COLLECT - Flag whether locks should only be collected first
I think VARKEY Accept one value only.
Regards,
Narasimha -
Can anyone share the query for inventory aging report
Is there any standard reports for inventory aging in oracle ebs 12.1.3 ....... If not can anyone share the query for inventory aging report
Hi,
It may not be so simple as you are trying to reproduce the historical value. I believe you have to create a temporary table first. Or you may use Command feather to get the required data in advance.
Thanks,
Gordon -
I still need help with the Dictionary for my Nokia...
I still need help with the Dictionary for my Nokia 6680...
Here's the error message I get when trying to open dictionary...
"Dictionary word information missing. Install word database."
Can someone please provide me a link the where I could download this dictionary for free?
Thanks!
DON'T HIT KIDS... THEY HAVE GUNS NOW.oops, im sorry, i didnt realised i've already submitted it
DON'T HIT KIDS... THEY HAVE GUNS NOW.
Maybe you are looking for
-
Invalid call Statement method: {0} In sql server,please help me!
Connect to a sql server 2000 DB,and the table has a identity column. Run the code below: String strSql = "insert into attachments([FileName],FileLength,FileContent) values(?,?,?)"; PreparedStatement pstmt = connection.prepareStatement(strSql); pstmt.
-
Strange behaviour when using connection pooling with proxy authentication
All I have developed an ASP.NET 1.1 Web application that uses ODP.NET 9.2.0.4 accessing Oracle Database 8i (which is to be upgraded to 10g in the coming months). I have enabled connection pooling and implemented proxy authentication. I am observing a
-
HELP !! Urgent !! Object in contexts
Hello, I have really urgent task to do. I need have access to object kept in <input type="file"> object. Is it possible to get the object without submitting the form ?? I suppose that page has to hold the object somewhere but have no idea how to acce
-
When I go to websites the right scroll bar does not appear
hen I go to websites the right scroll bar does not appear
-
When you delete one member from the outline what will be status of the block?