Advanced grouping help
Hi,
My tables holds data like this.
Region Agent Product Category Sale
West Agent1 P1 C1 2
West Agent1 P2 C3 3
East Agent1 P4 C4 2
East Agent2 P1 C1 5The report we want to generate should look like this
Region TotalSales(Total Sales from this region Top 5 Agents $ Top 5 Products $ Top 5 Category $
West 200 Agent 1 25 P1 18 C1 23
Agent 2 15 P2 15 C2 21
Agent 3 15 P3 12 C3 21
Agent 4 10 P4 7 C4 20
Agent 5 9 P5 6 C5 6
East 400 Agent 4 P3 75 C5 123
Agent 7 P7 30 C8 111Basically everything is pivoted on Region,
Basically what we have is
Columns 1, 2 - sum(sales) group by region
Columns 1, 3, 4 - sum(sales) group by region, agent
Columns 1, 5, 6 - sum(sales) group by region, product
Columns 1, 7, 8 - sum(sales) group by region, category
I'm on 10.2.0.3 and this has to be in SQL (no PL/SQL). I was thinking on using grouping sets but was getting a little confused. I had a temp table using (WITH AS), first grouped by all the columns then grouping by seperately. I was planning use PARTION and rownum to get the top 5 part. I can do this for each individual group by, but all put together seems a little confusing.
So just wanted to put my question out there in case some one has already achieved this.
I don't think so it is so difficult. Is this what you are looking at? First query gives you data based on the sales. The second query gives the region wise sales with agentid, category and product of the top two sales in each region.
SQL> with sample as(
2 select 1 regionid, 12 agentid, 21 productid, 31 category, 12 sale from dual
3 union all
4 select 1, 12, 21, 31, 3 from dual
5 union all
6 select 1, 13, 21, 32, 3 from dual
7 union all
8 select 1, 13, 22, 31, 5 from dual
9 union all
10 select 1, 14, 24, 33, 7 from dual
11 union all
12 select 2, 16, 21, 32, 2 from dual
13 union all
14 select 2, 14, 22, 32, 6 from dual
15 union all
16 select 2, 16, 22, 35, 8 from dual
17 union all
18 select 3, 12, 23, 36, 1 from dual
19 union all
20 select 3, 13, 23, 35, 8 from dual
21 union all
22 select 3, 15, 25, 33, 9 from dual
23 union all
24 select 3, 15, 26, 33, 10 from dual
25 ),
26 sample_ranked as
27 (
28 select regionid, sum(sale) over (partition by regionid) tot_sales,
29 row_number() over (partition by regionid order by sale desc) tot_rnk,
30 agentid,
31 productid,
32 category,
33 row_number() over (partition by regionid order by sale desc) rnk,
34 sale
35 from sample
36 )
37 select decode(a.tot_rnk, 1, a.regionid, NULL) regionid,
38 decode(a.tot_rnk, 1, a.tot_sales, NULL) total_sales,
39 a.agentid agentid,
40 a.productid productid,
41 a.category category,
42 a.sale sales
43 from sample_ranked a
44 /
REGIONID TOTAL_SALES AGENTID PRODUCTID CATEGORY SALES
1 30 12 21 31 12
14 24 33 7
13 22 31 5
12 21 31 3
13 21 32 3
2 16 16 22 35 8
14 22 32 6
16 21 32 2
3 28 15 26 33 10
15 25 33 9
13 23 35 8
12 23 36 1
12 rows selected.
SQL>
SQL> with sample as(
2 select 1 regionid, 12 agentid, 21 productid, 31 category, 12 sale from dual
3 union all
4 select 1, 12, 21, 31, 3 from dual
5 union all
6 select 1, 13, 21, 32, 3 from dual
7 union all
8 select 1, 13, 22, 31, 5 from dual
9 union all
10 select 1, 14, 24, 33, 7 from dual
11 union all
12 select 2, 16, 21, 32, 2 from dual
13 union all
14 select 2, 14, 22, 32, 6 from dual
15 union all
16 select 2, 16, 22, 35, 8 from dual
17 union all
18 select 3, 12, 23, 36, 1 from dual
19 union all
20 select 3, 13, 23, 35, 8 from dual
21 union all
22 select 3, 15, 25, 33, 9 from dual
23 union all
24 select 3, 15, 26, 33, 10 from dual
25 ),
26 sample_ranked as
27 (
28 select regionid, sum(sale) over (partition by regionid) tot_sales,
29 row_number() over (partition by regionid order by sale desc) tot_rnk,
30 agentid,
31 productid,
32 category,
33 row_number() over (partition by regionid order by sale desc) rnk,
34 sale
35 from sample
36 )
37 select decode(a.tot_rnk, 1, a.regionid, NULL) regionid,
38 decode(a.tot_rnk, 1, a.tot_sales, NULL) total_sales,
39 a.agentid agentid,
40 a.productid productid,
41 a.category category,
42 a.sale sales
43 from sample_ranked a
44 where a.rnk <=2
45 /
REGIONID TOTAL_SALES AGENTID PRODUCTID CATEGORY SALES
1 30 12 21 31 12
14 24 33 7
2 16 16 22 35 8
14 22 32 6
3 28 15 26 33 10
15 25 33 9
6 rows selected.
SQL> Cheers
Sarma.
Similar Messages
-
Advanced Search Help in PCUI & adding fields to SRES screen structures
I have linked the application COMM_IBASE to the POST_CODE1 field in CRMM_ACCOUNT (SRES area - field group ACC_SRES_CITY). When the user clicks the drop-down icon next to the post code field, a new window opens which shows COMM_IBASE.
We use our IBase to hold locations/addresses.
Is it possible to set up the system such that on selection of an IBase component, relevant address fields of that component are sent back to corresponding fields in the calling application, CRMM_ACCOUNT? Namely, Post code, street, city, country, region? I think my problem might be that these fields are not available in the screen structure of the COMM_IBASE Search Results area (CRMT_BSP_IBASE_RESLIST). How should you go about extending this structure? I can't see how it can be done using the EEW in the way you would extend, say, a service order.
I have the cookbook in front of me, but am finding sections 6.1.3.2/3 a little reticent here.
Thanks,
Alex.I solved it.
It wasn't too complicated, either, so I suspect my difficulty was down to me being totally unfamiliar with the PCUI (I usually do ICWC development) and this being the first PCUI requirement I have ever been given to work on.
Anyhow, if any other newbies are interested in how I implemented advanced F4 help to integrate searching of an IBase of addresses with postcode field of BP creation, then please reply to this post and I will give details.
Alex. -
when i convert a word file with a hyperlinks to a PDF file it doesn't work ?? thanks in advance for helping me
using microsoft word.
the hyperlink doesn't work in the pdf file (adobe reader).
adobe reader xi.
my operating system windows 8.1.
the attached screen is appeared. -
I upgraded my Firefox and my home page (which I love) is GONE. Not sure how to get it back. I still have my bookmarks though. Thanks in advance for helping me.
If that didn't help then see this article for more suggestions:
* [[Firefox has just updated tab shows each time you start Firefox]] -
Hi everyone, I did a software update, but when I run it I get an (0Xc000007b), what should I do? Thanks in advance for help
...07b Problems http://forums.adobe.com/thread/1355374?tstart=0
-
Calling the advance search help using f4 help
Hi
I have a question.In Items assignemnt blcok of the opportunity page for product ID field there is an f4 help associated with it. When we click on f4 help it will open the standard product serach in a popup where we can serarch for the products. and select the product from results.
But my requirment is to call the advance search help of the products instead of standard serch help in the popup when we click f4 help and should beable to save the searches and retrive the saved sercahes.
Can any one help me out with this problem
Thanks,
SreekarHi,
If you do a search on this forum for the terms "search help exit" you will get a few threads that provide details on how you can achieve this. -
greetings,
i can't find another place for this question. i'm having problems registering our macintosh user's group. over the last couple weeks, i've sent several messages to the email listed for user's group help, but have not gotten any response. i'm not sure where else to turn to for help.
does anybody have any suggestions for how to get help registering our user's group?
thanks-
jefferyHave you gone this route:
_http://www.apple.com/usergroups/find/register/_
Joe -
Request for Sticky #2 - Advanced Group Policy Troubleshooting Help
GPOMG!
Group Policy driving you crazy? Here are some advanced troubleshooting tools (beyond RSOP, GPRESULT, etc.) that may be helpful. For first level troubleshooting, check out this link:
http://technet.microsoft.com/en-us/library/cc787386(v=WS.10).aspx
EVENT VIEWER (NEW & IMPROVED!)
Event viewer in Windows 7 has more detail about Group Policy. Start your event viewer (may need to run as an admin. account). Navigate to:
Applications and Services Logs>Microsoft>Windows>GroupPolicy>Operational
Here you will find events that are related to Group Policy processing. You can determine how long it takes to run the various pieces of your particular GP as well as diagnostic information that can be very helpful when trying to figure out what is happening
with GP.
http://technet.microsoft.com/en-us/library/cc749336(WS.10).aspx
Events 4016 and 5016 show the start and end of processing of groups of policies, including how long it took to apply each one in the end event.
Event 5312 shows policies that will be applied, and 5317 shows policies that are explicitly filtered out.
Events 8000 and 8001 respectively show the total processing time for computer boot and user boot GP processing, and 8006 and 8007 show the same for interim/periodic GP processing.
GPLOGVIEW TOOL
A similar tool is called GPLOGVIEW. You must run this from the elevated command prompt. It will produce a XML, HTML, or simple text file of the GP events for export and review. You can even do a live monitor while you run GPUPDATE /force.
http://technet.microsoft.com/en-us/magazine/dd315424.aspx
GPSVR/GPSVC LOG FILE
If the normal tricks above don’t provide you with enough information, this should do it! There is a service called
GPSVR that gives you everything you ever wanted to know about Group Policy running on your workstation. Here is how to get more information from the GPSVR service in Windows 2008/Visa/Win 7.
Step 1: Enable logging in the Gpsvc.log file. To enable logging in the Gpsvc.log file, follow these steps:
Click Start, click Run, type regedit, and then click OK (might want to backup your registry first).
Make sure that you have the folder %windir%\debug\usermode, if the usermode folder is not there, then manually create it.
Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion
On the Edit menu, point to New, and then click Key.
Type Diagnostics, and then press ENTER.
Right-click the Diagnostics subkey, point to New, and then click DWORD Value.
Type GPSvcDebugLevel, and then press ENTER.
Right-click GPSvcDebugLevel, and then click Modify.
In the Value data box, type 30002 (as hex), and then click OK.
Exit Registry Editor.
Reboot machine.
At a command prompt, type the following command, and then press ENTER: gpupdate /force
You will find the Gpsvc.log file in the following folder: %windir%\debug\usermode
Step 2: I use Notepad ++ to analyze this log file. It can help you troubleshoot, step, by step what GP is doing as your workstation/user is getting logged in. Timing, access/permission issues, SID information and more are all included
in this log file.
Step 3: When you are done, change the value of HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Diagnostics|GPSvcDebugLevel to 0x00000000 to disable the debug log or else it will continue to grow.
Charlie NewmanHi,
I have posted an MST file which fixes this and other issues to the following thread here:
http://forums.adobe.com/message/2697135#2697135
Please post any feedback to that thread!
Kind regards,
Chris Hill -
Advanced Group Sorting Help Needed
In a previous thread,I was able to great two levels of hierarchy:
1) Group by Case Worker
2) All clients that pertained to their caseload (assigned client)
The initial problem was, it was pulling duplicate records because each client had multiple instances of treatment plans, but I was more concerned about the most recent begin date. within Section Expert > Details, I use the following formula
{AZCLPLAN.BEG_DATE} <> maximum ({AZCLPLAN.BEG_DATE}, {CDCLIENT.CASE_NUM})
This successfully pulled the most recent treatment plan for the client record, ignoring all previous records. However, the case worker wants to see their caseload sorted by which treatment plans are ending first (AZCPLAN.END_DATE). When I add a new group END_DATE, move it up the hierarchy for sorting, it breaks my duplicate record sort rule.
In laymen terms, after the report strips the duplicates only showing the most recent records, I want to do a sort by dates thereafter. how is this possible?I tried adding Record Sort Expert. By default the two hierarchy groups are locked at the top tiers. The 3rd item is solely the record file: ..END_DATE set to ascending.
Under the Caseworker Group (highest tier) , next group in line is CASE_NUM. therefore, once a group is in place, it trumps anything below it (currently sorted by chart/case number). I tried changing the Group Expert > CASE_NUM to "original order" , but no luck. -
Hi,
Opportunity Group drop down menu, to remove the some of the products. We do not want historically information to be affected by this change. We just want to have these products marked in such a way that they no longer show up in the drop down menu, but that previous opportunities that were created for these products remain complete.
Please help me for this issue.
How to hide thopse opportinity groups from drop down list.
Advance thanks
DSTHi,
You can delete the Opportunity Group contents in SPRO under Settings for Opportunity under Define Opportunity Group, select and delete the groups.
Best Regards,
Johnny. -
Trash and user group help!
why do i need to type in password when i delete things? how do i remove it?
and i can't delete items directly from the dock as well. like opening from the downloads folder and dragging the file to trash. i have to bring open up Finder and delete from the folder directly.
another issue is that am i able to remove the gues user from my start up screen? i've already disabled it from the user groups but i still see it in my login screen.
one last problem, is it a norm to have current leakage for the MBP? i've been having frequent shocks from the 2 bottom corners of it when i plug it in to a power source. i bought it from an authorized retailer and using it in the country where i've gotten it from. i've just gotten my mbp about 3 weeks back.
thanks for replying my queries!Hi,
Yeah in ACS 3.1 its under the Shared Profile Components page. In ACS 4.1 its directly under the user groups or under SPC page.
You need to check the box for "define ip based access restriction" and deny access for all other groups to the wireless access points network device group.
ACS 3.X)
1. Denied Calling/Point of access restrictions
2. AAA Clients =UPS_PDU (Power Supplies)
3. Port = just put a * for all
4. Src IP address = just put a * as well
SUBMIT to SAVE
Create a second one for the other group like so:
1. Denied Calling/Point of access restrictions
2. AAA Clients =Routers_Switches
3. Port = just put a * for all
4. Src IP address = just put a * as well
Click submit to save it.
Go to the ACS User groups section and select the Network Administrators Group " that don't need access to the UPS's" and apply the NAR you created to that group. Do the same for the other grouping.
(ACS 4.X)
Go directly under the "user groups" and create the NAR under there. No need to go under the Shared Profile Components section
Hope this helps and let me know if you need further assistance or explanation.
Craig -
Integrated Sound Blaster Audigy ADVANCED HD Help
Hey guys, I was hoping maybe someone could help me... I have the Integrated Sound Blaster Audigy ADVANCED HD driver but its only for 32-bit operating systems. I am running windows 7 64 bit and I was wondering if there are any 64 bit drivers around since I couldn't find any on google. If not, are they planning to release one anytime soon? Thanks for the help.
You know I did that and it worked. Thanks you.
I should mention that when I contiued the activation it failed to load giving an error saying no audio driver. So, I went to the Dell website and downloaded the sigmatel audio file, re-installed and it worked. However the saga continues as it only sees 2. speakers when I have a 5 speaker system and i can't figure out how to change that settings. I followed the help instruction but under the confiuration I am not given any option. so still some work to be done. I would have expected the process to be simpler, you really would need to be quite skilled to be doing all this tweaking, if you were a novice you'd be lost! -
Post Author: bddgp
CA Forum: General
I've tried the documentation, online help, my Crystal Reports book and the web, and can't find the answer! My problem:My database contains a list of people and events they have attended. I have created a report which generates a certificate for each person, and lists all the events they have attended. So far so good.There is a group set on the person's ID field, which is unique. This works well, except I would like the certificates to be ordered by the person's last name, not their ID number.Thanks in advancePost Author: V361
CA Forum: General
This is for CR XI.... Well if you group by ID, unless you have multiple ID's that are the same, grouping by name won't get you what you want. Go to Report, Group Expert, select your name field from the list, when you add the field, the group will go to the bottom, of the list, if you look to the right of the Group By window you will see a small blue arrow, click on it, and hopefully the groups will change position. That should at least get you started..... -
Hi, I need help with creating an Advanced queue. I have already created the queue table but when I try to create the queue it says that it was sucessful, yet I can not find it. Also I need help with creating a SQL subscriber such that some sort of SQL code with enqueue a message, and the subscriber will dequeue and print it out or something. I am also going to set up a ESB process to do the some thing.
Here is my queue_table code:
dbms_aqadm.create_queue_table( queue_table => 'TEST_QUEUE_TABLE',
queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE',
multiple_consumers => True);Hey demorgan, I get this error with the demo. At some point I have to make a procedure with this:
SELECT TO_NUMBER(SUBSTR(dbms_crypto.randominteger,3,1))
INTO x
FROM dual;I get this error: ORA-00904: : invalid identifier
Also how do I view what is on a queue? This demo does not show that. -
Captivate 4 advanced interaction help needed
I have a captivate 4 project that's due tomorrow for my new job and I can't figure out why it is not working correctly. I have spent the last 40 hours trouble shooting and have not been able to figure it out. Please help me out if you can. I have a 47 slide scenario that works right if you answer all the questions correctly. However, when you don't answer a question correctly the redirection is messed up even though it looks right in captivate 4. the back and forward buttons are not going where they should and at times you are advanced to another question without having answered the previous question. Here's the flash and captivate 4 files. I don't know what else to do and would greatly appreciate suggestions.
http://people.tamu.edu/~emmanuel.okafor/Quickr-final2.swf
http://people.tamu.edu/~emmanuel.okafor/Quickr-final2.cpHello,
Just had a quick look at your CP-file but opened it in CP5 so not totally sure: in the Quiz settings, you have only allowed 1 attempt for the Quiz (Quiz preferences, Pass or Fail) is that correct? You allow multiple attempts (2 or 3) in the individual questions, but this is normally meant to retake the question immediately. I had such an example on slide 18. Not sure, but please try to allow more than 1 attempt for the quiz itself.
Lilybiri
Maybe you are looking for
-
Hi, everyone! I don't know if this question has been answered, but I recently lost my photos on my iPhone. My iPhone memory was full, so I decided to transfer some of the photos on my iPhone onto iPhoto to clear up some space. (In hindsight, I probab
-
Using an external hard drive for some media while leaving the rest on the desktop
How can I access ripped DVDs on an external hard drive through iTunes while leaving our music and downloaded media on the desktop hard drive? I'm in the process of ripping all of our DVDs so we can watch them using our Apple TV. I can't figure out ho
-
Green box with registration marks appears from nowhere
...and I'd like to get rid of it, but how and what is it? In any AICS3 document I open, my default is now an art board that is 200"x200" with a green rectangle about 60"x12" in its center. The green rectangle has registration marks on its corners. Ev
-
WLS 92MP1: Application Poller issue Too many open files
Hi, We have a wls92mp1 domain on linux AS4(64bit) with Sun jdk 1.5.0_14. It contains only Admin server where we have deployed the application. Over a period of time the server start showing up below message in the logs. We have not deployed the appli
-
Running Tomcat 4.0.1 on RH7.0
I try to run Tomcat 4.0.1 on RH7.0, [root@backup bin]# ./startup.sh but I get this error, Guessing CATALINA_HOME from catalina.sh to ./.. Setting CATALINA_HOME to ./.. You must set JAVA_HOME to point at your Java Development Kit installation then I s