Group by at each level
Hi Guru's,
Many Thanks for Previous help.
I have set of input and i need the output in some manner.
I tried to solve it but not able to think how can i do this...i tried to use cursor and loop concept but values in xyz column increase then nos. of cursor also get increase.
Please help me on this.
Specially the values highlighted in bold .
Input:
abc
xyz
Numerator
Denominator
a1
a
12
23
a1
b
13
24
a1
c
18
29
a2
d
18
29
a2
e
12
11
output:
cde
lmn
Numerator
Denominator
a1
a
12
23
a1
b
13
24
a1
a,b
12+13
23+24
a1
a,c
12+18
23+29
a1
b,c
13+18
24+29
a1
a,b,c
12+13+18
23+24+29
a2
e
12
11
a2
d
18
29
a2
e,d
12+18
11+29
Thanks,
may be...
SQL> with t
2 as
3 (
4 select 'a1' abc, 'a' xyz, 12 numerator, 23 denominator from dual
5 union all
6 select 'a1' abc, 'b' xyz, 13 numerator, 24 denominator from dual
7 union all
8 select 'a1' abc, 'c' xyz, 18 numerator, 29 denominator from dual
9 union all
10 select 'a2' abc, 'd' xyz, 18 numerator, 29 denominator from dual
11 union all
12 select 'a2' abc, 'e' xyz, 12 numerator, 11 denominator from dual
13 )
14 select distinct abc
15 , ltrim(sys_connect_by_path(xyz_1, ','), ',') xyz
16 , ltrim(sys_connect_by_path(nu, '+'), '+') numerator
17 , ltrim(sys_connect_by_path(de, '+'), '+') denominator
18 from (
19 select abc
20 , xyz
21 , regexp_substr(xyz, '[^,]+', 1, level) xyz_1
22 , regexp_substr(nu, '[^+]+', 1, level) nu
23 , regexp_substr(de, '[^+]+', 1, level) de
24 , row_number()
25 over(partition by abc, xyz
26 order by regexp_substr(xyz, '[^,]+', 1, level)) rno
27 from (
28 select abc
29 , ltrim(sys_connect_by_path(xyz, ','),',') xyz
30 , ltrim(sys_connect_by_path(to_char(numerator), '+'),'+') nu
31 , ltrim(sys_connect_by_path(to_char(denominator), '+'),'+') de
32 from t
33 connect
34 by nocycle xyz != prior xyz
35 and abc = prior abc
36 )
37 connect
38 by level <= length(xyz) - length(replace(xyz, ',')) + 1
39 and prior xyz = xyz
40 and prior abc = abc
41 and prior sys_guid() is not null
42 )
43 where connect_by_isleaf = 1
44 start
45 with rno = 1
46 connect
47 by abc = prior abc
48 and xyz = prior xyz
49 and rno = prior rno + 1
50 order
51 by abc
52 , length(xyz)
53 , xyz;
ABC XYZ NUMERATOR DENOMINATOR
a1 a 12 23
a1 b 13 24
a1 c 18 29
a1 a,b 12+13 23+24
a1 a,c 12+18 23+29
a1 b,c 13+18 24+29
a1 a,b,c 12+13+18 23+24+29
a2 d 18 29
a2 e 12 11
a2 d,e 18+12 29+11
10 rows selected.
SQL>
Similar Messages
-
Repeating a group element on each page of a report.
I have a report where I need to repeat a group element on each page. The element is from the first group in the data. It is in the center group. Currently, the values from this group only print when the group changes. Everything I try does not work. Does anyone have any ideas. I am attaching a sample of the data. Along with the rtf document. I am using the BI Publisher plug in in Word to create the template.
Data
<?xml version="1.0" encoding="UTF-8"?>
<POLLEDTICKETRPT>
<USERCD>klockhar</USERCD><POLLDATE>03/24/2009</POLLDATE>
<LIST_CENTER>
<CENTER>
<CENTER_CD>0039</CENTER_CD>
<CENTER_NAME>CROSS PLAINS QUARRY</CENTER_NAME>
<LIST_TRANSDATE>
<TRANSDATE>
<TRANS_DATE>03/11/2009</TRANS_DATE>
<LIST_CUSTOMER>
<CUSTOMER>
<CUSTOMER_NBR>33221477</CUSTOMER_NBR>
<CUST_NAME>TDOT DISTRICT 32-GALLATIN</CUST_NAME>
<LIST_JOB>
<JOB>
<JOB_CUST>33221477</JOB_CUST>
<JOB_CUST_NAME>TDOT DISTRICT 32-GALLATIN</JOB_CUST_NAME>
<RGI_JOB_NBR>2008</RGI_JOB_NBR>
<QUOTE_ID>0</QUOTE_ID>
<LIST_COSTCODE>
<COSTCODE>
<COSTCODING/>
<COST_CNTR/>
<COST_ACCT/>
<PROJECT_NBR/>
<PROJECT_TASK/>
<LIST_TICKET>
<TICKET>
<TICKET_NBR>5000021</TICKET_NBR>
<ORIGIN_CD>TSCC</ORIGIN_CD>
<REFERENCE_NBR>254510</REFERENCE_NBR>
<VOID_IND>N</VOID_IND>
<STATE_CD>TN</STATE_CD>
<MEASURE_SYSTEM>S</MEASURE_SYSTEM>
<LOCATION>THANK YOU</LOCATION>
<PO_NBR>POS-254510-C</PO_NBR>
<TAX_CODE>4</TAX_CODE>
<PRODUCT_CD>000003</PRODUCT_CD>
<HAUL_ZONE_CD/>
<INVENTORY_STATUS>PR</INVENTORY_STATUS>
<HAULER_NBR/>
<RGI_TRANSPORT_CD>FU96</RGI_TRANSPORT_CD>
<HAUL_RATE> .00</HAUL_RATE>
<MAT_RATE> 8.50</MAT_RATE>
<NET_TONS> -7.96</NET_TONS>
<MAT_SALES_AMT> -67.66</MAT_SALES_AMT>
<HAUL_AMT>0</HAUL_AMT>
<TAX_AMT>0</TAX_AMT>
<SEV_TAX_AMT>0</SEV_TAX_AMT>
<SEV_TAX_IND>N</SEV_TAX_IND>
<VALID_NET_TONS> -7.96</VALID_NET_TONS>
<VALID_SALES_AMT> -67.66</VALID_SALES_AMT>
<VALID_HAUL_AMT> .00</VALID_HAUL_AMT>
<VALID_TAX_AMT> .00</VALID_TAX_AMT>
<VALID_SEV_TAX_AMT> .00</VALID_SEV_TAX_AMT>
<CASH_TONS> .00</CASH_TONS>
<CASH_SALES_AMT> .00</CASH_SALES_AMT>
<CASH_TAX_AMT> .00</CASH_TAX_AMT>
<CASH_SEVTAX_AMT> .00</CASH_SEVTAX_AMT>
<CASH_HAUL_AMT> .00</CASH_HAUL_AMT>
<TRADE_TONS> -7.96</TRADE_TONS>
<TRADE_SALES_AMT> -67.66</TRADE_SALES_AMT>
<TRADE_TAX_AMT> .00</TRADE_TAX_AMT>
<TRADE_SEVTAX_AMT> .00</TRADE_SEVTAX_AMT>
<TRADE_HAUL_AMT> .00</TRADE_HAUL_AMT>
<INTRA_TONS> .00</INTRA_TONS>
<INTRA_SALES_AMT> .00</INTRA_SALES_AMT>
<INTRA_TAX_AMT> .00</INTRA_TAX_AMT>
<INTRA_SEVTAX_AMT> .00</INTRA_SEVTAX_AMT>
<INTRA_HAUL_AMT> .00</INTRA_HAUL_AMT>
<INTER_TONS> .00</INTER_TONS>
<INTER_SALES_AMT> .00</INTER_SALES_AMT>
<INTER_TAX_AMT> .00</INTER_TAX_AMT>
<INTER_SEVTAX_AMT> .00</INTER_SEVTAX_AMT>
<INTER_HAUL_AMT> .00</INTER_HAUL_AMT>
<CASH_PR_TONS> .00</CASH_PR_TONS>
<CASH_NP_TONS> .00</CASH_NP_TONS>
<CASH_MI_TONS> .00</CASH_MI_TONS>
<TRADE_PR_TONS> -7.96</TRADE_PR_TONS>
<TRADE_NP_TONS> .00</TRADE_NP_TONS>
<TRADE_MI_TONS> .00</TRADE_MI_TONS>
<INTER_PR_TONS> .00</INTER_PR_TONS>
<INTER_NP_TONS> .00</INTER_NP_TONS>
<INTER_MI_TONS> .00</INTER_MI_TONS>
<INTRA_PR_TONS> .00</INTRA_PR_TONS>
<INTRA_NP_TONS> .00</INTRA_NP_TONS>
<INTRA_MI_TONS> .00</INTRA_MI_TONS>
</TICKET>
</LIST_TICKET>
</COSTCODE>
</LIST_COSTCODE>
</JOB>
</LIST_JOB>
</CUSTOMER>
</LIST_CUSTOMER>
</TRANSDATE>
RTF Template
DISPLAY CENTER
S M
FOR EACH CENTER
SET CENTER
CENTER: CENTER_CD CENTER_NAME
FOR EACH TRANSDATE
TRANSACTION DATE: TRANS_DATE
FOR EACH CUSTOMER
FOR EACH JOB
Customer: JOB_CUST JOB_CUST_NAME
Job: RGI_JOB_NBR Quote Id: QUOTE_ID
FCC
group COSTCODE by COSTCODING
Cost Center: COST_CNTR Cost Acct: COST_ACCT Project: PROJECT_NBR Task: PROJECT_TASK
Ticket Nbr ORGCD OrigTck V ST Location Po Nbr Tax Cd Prod Code ZN Hauler Truck Haul Rate UnitPrice Tons SalesAmount
F TCK#M CODE OTCK# V ST LOCATION PO_NBR TC PROD HZ HAULER TRUCK 0.00 0.00 0.00 * 0.00 EPost Author: Guy
CA Forum: General
Hi,
You should add a first level of grouping in your subreport on a fake formula field with a constant value. Put your header and footer information in this group header and footer. In the group option make sure to check the "repeat group header on each page option".
This group will act as a page header + footer within your subreport.
good luck!
Guy -
Is there a way to fix particular percent of slice area to each level value
Is there a way to fix particular percent of slice area to each level value in a flash pie Chart?
I need a pie chart for Distribution of Escalations by Status; here I have following status Record in my table
5 record for Status: Reopen
2 record for Status: Escalated
2015 record for Status: Closed
12 record for Status: Open
1000 record for Status: WIP
So I am not able to see data in pie chart for Status Reopen, Escalated, and Open, bcz all levels are overlapping each other
So I want to fix particular percent of slice area to each level value(Reopen, Escalated, Closed , WIP and Open)
For e.g. I want to show 15% slice area of chart for Escalated, 10% for Reopen, 20% for Open
25% for WIP and 30% for Closed. So i can see record for all status while that have less data as compare to other
status.
I am using following query for pie Chart….
SELECT
''javascript:dhtml_GetReport_r2(0,0,0,0,0,''''''||''''||STATUS||''''||'''''',0)'' link,
nvl(STATUS,''Unknown'') label,
COUNT(ISSUE_ID) Escalations
FROM XYZ_ITR_MAIN
WHERE 1=1 GROUP BY STATUS;
Thanks
Rathore
Edited by: Rathore on 01-Apr-2010 02:37Your requirement makes sense from the point of visibility but doesn't make sense having the facts in mind that 2 out of 3034 is always 0,000659195% no matter how you look at it. And a pie chart is always going to give you exactly that. The only thing you can do is to manipulate your data but then what a user will see is not going to match with the reality. So, the only solution I see is to make a bigger chart. Exploding a pie chart is also an alternative but I don't think you can do that currently with the flash charts.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
Have a gap in detail of first page and not display group footer on each pag
Please help me about Memo field in SubReport in CrystalReportXI. I have a SubReport that need to display pageheader, detail, page footer, and in detail of subreport contains memo field and set the property of this text box to "Can Grow" = Yes .However, CrystalReportX does not support to display pageheader, pagefooter in SubReport. So. I have created a formular FakePageHeader that has code as
"WhileReadingRecords;
true"
and group in this field and checked option repeat group header on each page and right click Section Expert->check print at Bottom of page for Group Footer.
This problem is when I preview Subreport. It display text in group header and a gap in detail of first page and view next page, the subreport display right data of memo field. But the report still not display group footer on each page.
How do I can remove a gap in first page and display group footer on each page?
Thanksin subreport in format for the memo field uncheck keep object together.
You can not force group footers to repeat on each page.
I have not tried this but you might be able to capture the data you want to show in SR page footer and display in main report page footer, using shared variables.
Ian -
Group heading on each page..
I am trying to get BI Publisher to output a group heading on each page of my report.. At this time, I am using the Word/RTF version to build my layout.
I have information in the word document header and footer, and tried adding the group by column in the header, but that only returned my first group value, always!.
is there a safe solution? I have looked through the forum and seen many questions on this and not any simple answers..
Thank you,
Tony Miller
UTMB/EHNJust checking to see if you received the e-mail and the file that was attached... I am still looking for solutions to the issue..
Thank you,
Tony Miller
UTMB/EHN -
Repeating Group header on each page
Hello Everybody,
I have two groups in my report. For my first group value, i have given report - group expert - options and checked "Repeat group header on each page" assuming that my first group values will appear on each page. But it is not doing so. In one of the page the group footer values are appearing without my first group values.
I belive my problem is my second group values are ending in one page and first group values are extended to next page . Can any one please hep me.if that is the case Narukonda 1, there are several sap notes dealing with this issue...please see this sap note [here |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313333333133373339%7D.do]which deals with both orphaned group footers and group headers.
-
How to repeat group head on each page
I have problem with repeat group heaf on each page, I've ticked the option 'Repeat group head on each page' from the Change Group Option. But the group head didn't appear on each page when I previewed the report. Does anyone have a solution/explaination to this?
CheeersSorry Gents, I did't make my porblem clear.
To James Terry
Yes, My reports contain one or more sub-groups (only group 1's group header needs to be repeat on each page).
To Graham Cunningham
I found pages , containing only group 1's group footer summarized info, don't display group 1's group header. Just like what you said ' It will only repeat on pages that display group information'. Is this a bug or sort of default rule? What else can I do if I want the group header to repeat on each page no matter whether there is group info or not, besides moving the info from group header to pager header?
Thanks a lot.
Regards
Joseph -
Repeat Group Header On Each Page not working
Hi,
I have a report that have 3 subreport, and in the Subreport, there is Group Headers that enabled the option "Repeat Group Header On Each Page". It works fine in the CR10 preview. However, the header won't repeat in the PDF generated by JRC.
Any Idea?
Thanks a lot!!Hi,
Doesthe JRC engine uses CR10 jars or XI\R2 jars? Can you possibly try it with latest set of Eclipse jars? You can download it from Diamond.
Thanks
Aasavari -
Repeat group footer on each page
Hi all,
I have a regular report with 1 Group. My problem is that my report doesn't repeat group footer on each page. I know that in Grouping options there is an option for "Repeat Group Header on each page" checkbox which makes the Group Header print on each page. I've found that Header and Footer both work together and that if you print Header it will print footer as well. The thing is I have paging functionality (<a href='http://www.crystalreportstrainingbootcamp.com/resources/trainers_talk_detail.asp?Title=03'>click here for paging details</a>) in my report in the Group, so once it reaches 14 lines in Details it goes to the next page, prints the GROUP HEADER but not the GROUP FOOTER on each report page.
Does anybody know why?
I found the following topic: <a href='http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do;jsessionid=90BF3D79A308CCF6B58F1E2656225CDD?cmd=displayKC&docType=kc&externalId=c2004981&sliceId=&dialogID=360384&stateId=1%200%20356275'>Creating a fake group header for orphaned group footers</a> but it's for CR 7. Was it resolved in newer releases of CR or it still needs a work around? I'm not even sure if that will fix my problem...
Thank you,
TatyanaHello,
please give us the verison of your Crystal Reports product that we can investigate
Regards,
Falk -
Repeat Group Header on Each Page in Subreport won't reflect when generate by JRC
Hi All,
I have a report that contain several Subreports. Inside the Subreport, there are Group Header section. I have checked the option of "Repeat Group Header on Each Page". It works fine when I preview in Crystal Report. But when I using JRC to generate the report result. The group header only display on the first page of the group details.
More, Crystal 10 Common Monthly Hot Fix (English) already installed.
Any idea?
Thanks a lot for your help!
DonaldHi,
Doesthe JRC engine uses CR10 jars or XI\R2 jars? Can you possibly try it with latest set of Eclipse jars? You can download it from Diamond.
Thanks
Aasavari -
How to create a custom measure for each level of a dimension
Hi all!
Can Anyone please explain me with an example, how to create a custom measure for each level for a dimension? I dont mine if you use
one or more measures.
thanks in advance
hope someone helps me.For example:I create a dimension for product_dim witch has 4 levels:total, class, family and item:
d_aben18
n1_aben18
n2_aben18
n3_aben18
n4_aben18
herarchy:h_aben18
cube:cubo_aben18
measure:med_aben18
I create this code to fetch the data to the dimension:
TRAP ON CLEANUP
SQL DECLARE c1 CURSOR FOR SELECT-
total_product_id,1,'N1_ABEN18',total_product_dsc,-
class_id,1,'N2_ABEN18',total_product_id,class_dsc,-
family_id,1,'N3_ABEN18', class_id, family_dsc,-
item_id,1,'N4_ABEN18',family_id,item_dsc-
FROM PRODUCT_DIM
"OPEN THE CURSOR
SQL OPEN c1
"FETCH THE DATA
SQL FETCH c1 LOOP INTO-
:APPEND D_ABEN18, :D_ABEN18_H_aben18_HIERDEF,:D_ABEN18_N1_aben18_LEVELDEF,:D_ABEN18_long_description,-
:APPEND D_ABEN18, :D_ABEN18_H_aben18_HIERDEF,:D_ABEN18_N2_aben18_LEVELDEF,:D_ABEN18_parentrel,-
:D_ABEN18_long_description,-
:APPEND D_ABEN18, :D_ABEN18_H_aben18_HIERDEF,:D_ABEN18_N3_aben18_LEVELDEF,:D_ABEN18_parentrel,-
:D_ABEN18_long_description,-
:APPEND D_ABEN18, :D_ABEN18_H_aben18_HIERDEF,:D_ABEN18_N4_aben18_LEVELDEF,:D_ABEN18_parentrel,-
:D_ABEN18_long_description,-
"SAVE THE CHANGES
UPDATE
COMMIT
CLEANUP:
SQL CLOSE c1
SHOW 'KK2'
Then I create a cube with use compression off, and in rules sum for example.
After, I create a measure and I select Override the aggregation specification for the cube, in rules I put nonadditive and I would like to create aprogram to assign distinct values to each level of the dimension. For example, I put 1, 2 3, and 4 values, but at the end I would like to put count(distinct(values)).
for that I create another program:
VRB D_RETURN DECIMAL
if D_ABEN18_N1_ABEN18_LEVELDEF eq 'N1_ABEN18'
then D_RETURN = 1
if D_ABEN18_N2_ABEN18_LEVELDEF eq 'N2_ABEN18'
then D_RETURN = 2
if D_ABEN18_N3_ABEN18_LEVELDEF eq 'N3_ABEN18'
then D_RETURN = 3
if D_ABEN18_N4_ABEN18_LEVELDEF eq 'N4_ABEN18'
then D_RETURN = 4
else d_return=26
return d_return
"SHOW D_RETURN
cubo_aben18_med_aben18_stored=d_return
but it doesnt work.I dont know how to put to assign or to see what I want.
I report the measure, or I report the program, but then how can I see the values of the measure?
thanks in advance -
To restrict a object to a particular Group at the Universe level
Hi,
I have a object which should be restricted only to a particular group at the universe level.So when i define the universe we have to have explicit security that will restrict access to this object information from reports and from ad-hoc queries.I should restrict the object only to the particular group by a role based security.
Please help me out in this case.
Thanks in advance,
MadanHi Madan,
Please follow the below steps:
(In Designer)
1) Open Island Resort Marketing universe or any universe in Designer.
2) Goto Tools -> Manage security -> Manage Access Restrictions.
3) Click on New option - > Give the Restriction name - >click on Rows tab - > Click on Add button (New Row Restriction window comes) -> give table name For example:"Resort_Country" in the Table text box, under the Where Clause "Resort_Country.COUNTRY = @Prompt ('Which country?u2019,u2019 A',, MONO,FREE)"-> Click OK -> Click Ok.
4) Click on Add user or group - >Select the user ->Ok.
5) Click on Apply -> Click OK.
6) Save the universe and export it into the repository.
7) Cretae the new report (webi/deski) from the user the one who belongs from this group.
Hope above steps will helps you.
Regards,
Deepti Bajpai -
Different chart for each level hierarchy in report designer
Is there a way to display a different chart for each level of the hierarchy in a report designer? I want a different chart for each level. That is, if there are 5 nodes in level 4, I want 5 different nodes. Is there a way to do this? I tried to insert the chart inside a cell in each level, but it shows the same chart for all nodes instead of a different chart for each node.
Has any one tried using a context sensitive chart? According to this, it seems like this should be possible, but I am having no luck.
http://help.sap.com/saphelp_nw70/helpdata/en/47/a99a0a5fdb0985e10000000a42189c/frameset.htm -
Hello all,
What I'm trying to do is generate a report of all groups owned by a specific user, along with the group memberships, and output it all to a single .csv file. In the .csv file, I would like to have the group names as the column headers, and underneath
the group name, list all the members of the group down through the column. So for example, if User1 owns 3 groups, the output would look like:
What I'm having trouble with is outputting the objects to the .csv using New-Object psobject, and I'm starting to wonder if there is an easier way to do this and my brain is just fried.
Any ideas?OK so I can try and give some code here, but I'm asking more of a concept question about how PowerShell builds objects so I'm not sure it will help....
$User = "User1"
get-adgroup -filter {managedby -eq $user} -pr member | %{
$_.name
$_.member
OK so this is a simple script that outputs a group name followed by the membership, all in a single column. What I would like is for the group names to each be the header of a column, and have the membership listed underneath. For example:
Is this possible in PowerShell? -
Mass processing Tcode for disaggregation of Prod group plan to Lower levels
is there a TCode to mass disaggregate the sales plan to FG forecast. I am looking for 'Mass Processing' function of what MC76 can do 'Product Group by Product Group.
Such processing should blow thro' intermediate level of Product group & then to next level which would be FERT materials.is there a TCode to mass disaggregate the sales plan to FG forecast. I am looking for 'Mass Processing' function of what MC76 can do 'Product Group by Product Group.
Such processing should blow thro' intermediate level of Product group & then to next level which would be FERT materials.
Maybe you are looking for
-
Cannot sync my IPhone without being tethered to my computer/Itunes
I have done all the updates and have the latest Itunes (10.5.2.11) and latest operating system (IOS5) and ICloud, on my IPhone (3G). It worked for a while; all I would have to do is get my phone close to the computer and it would sync. Now, it doesn'
-
i changed companies and had icloud with my old company - now i want to just use my personal id and can't change any icloud info to match my personal ipad id - i can't delete the icloud without the old company id and password which is not available to
-
Error while accessing EP: 500 Internal Server Error
Installed EP 6.0 SP3 on WAS 6.4 (ABAP+J2EE stack),DB->SQL Server, OS->Windows (no clusters involved). When we try to access EP (http://<servername>:50000/irj/portal), we get the following message. Application error occurs during processing the reques
-
I created some forms on my desktop with Acrobat 9 Pro (9.5) and was able to edit the forms but today the LifeCycle Designer either hangs or errors saying it has stopped working.I cannot create a new form. On my notebook where I have the same softwar
-
Extracting body with header and trailer multiple times from a multirow file
Hello Everyone, I am new to OSB and currently working on a project where I need to extract data from a flat file containing multiple rows of body and a single header and trailer in the following fashion: Original File: <Header></Header> <Details></De