How can I create "Sub Queries" in a select statement?

Hi all,
I need to create reports, which are not based on a single table but on several "sub-queries".
This would be the code, but I don't know how to solve that problem...
SELECT OGBI.*
FROM
(((select "OSSRALL"."FORECAST_OWNER", sum
("OSSRALL"."TOTAL_OPPORTUNITY_AMOUNT")
from "#OWNER#"."OSSRALL" "OSSRALL",
"#OWNER#"."TEAM_MAIN" "TEAM_MAIN",
"#OWNER#"."MA_MAIN" "MA_MAIN"
group by "OSSRALL"."FORECAST_OWNER")OGBI.APPSME1)
where "OSSRALL"."OPP_CLASS" = (EX_OTHERS)),
-- more are following
"#OWNER#"."OSSRALL" "OSSRALL",
"#OWNER#"."TEAM_MAIN" "TEAM_MAIN",
"#OWNER#"."MA_MAIN" "MA_MAIN"
WHERE
("MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"||' Mr'
like "OSSRALL"."FORECAST_OWNER" or
"MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"||' Mrs'
like "OSSRALL"."FORECAST_OWNER" or
"MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"
like "OSSRALL"."FORECAST_OWNER") and
("OSSRALL"."SALES_GROUP"="TEAM_MAIN"."NAME") and
("MA_MAIN"."MA_ID"=:P17_VB1)
thx a lot for your help.
kind regards Jan
Message was edited by:
Jan Rabe

Jan
Please can you post the full select statement and the DDL to create the tables? Or, provide someone access to the app on the Oracle server.
We can probably make these much more readable using table aliases and removing the owner unless you are doing this across schemas or via a wizard?
It looks like you are missing joins in your query - is this what you mean by subqueries? It is a good idea to move the join up before the WHERE clause if you can as this makes the query easier to manage.
Phil

Similar Messages

  • How can I create 'sub-routines'?

    …, a simplified description what I like to accomplish:
    I'd like to create a generator which lists the, say,  5 (in real: 11...) members of a team:
    1,2,3,4,5
    I'd like to have a drop-down-menu to select from a range of players (A,B,C,D,E,F,G,H), so position #1=player A, #2=C, #3=E, #4=F, #5=B ...
    that's easy .... learned that, did use the 'snapshot' function for a previous version of this generator.
    But!
    next season, it should be a sequence, each player appears after the other (and each item is a short animation, title, fade/in out of pic) - ...
    so, the animation of Player B could appear at 00:10 or 00:20 or 01:40 ...
    It would bloat my Motion project to infinity, if I put ALL player-animations at ANY optional time-line position (and in FCPX, I can select which animation at what time index)... in final version it's 23 optional players at 11 positions of the timeline = 253 'tracks'!
    Question:
    any smart idea how 'link' from the timeline of the Motion-project to some 'sub timeline'?
    in FCPX I would like to see 11 drop-menus; 1-11 defines the sequence of appearance, and I can select at each position any team-member...
    ... hope this makes sense ....
    maybe I'm thinking way too complicated ...
    k.

    Place your players inside a group (called Players). You can arrange the order any way you like, but top down will be more convenient.
    Move the playhead to the beginning, select the top (in the list) player) and type "O" to set an out point. From there, you should be able to hit the down arrow and type I - O to set a one frame in and out for each of the player images.
    Select the Players group and type K to clone it - name it Team. You now have an Image Sequence to work with.
    Replicate the Team image sequence. For each replicator, give it the Position Name. Turn the Shape to Line; Start and End Points at 0,0; Points 1.  Turn off Play Frames in the Cell Controls and use the Source Start Frame to pick the player for that position.
    You can duplicate Replicators (easier) or replicate the Team image sequence.
    Is that about what you wanted?

  • How can I create sub tasks in the UWL

    Hello All,
    I have a requirement where in I am pulling all the SAP Business Workplace notifications into the UWL. In UWL we want to have sub tasks or in other words we want to have selections based on subjects.
    For eg. In SAP if there are three workflows running for three diffrent tasks then in UWL I should have an option to choose among the three and have the notifications based on the selected subject.
    Let me know how this can be done. Looking forward to you.
    Regards
    DK

    Hi Dipendra,
    What i understood from your message is that  if you choose a Task for
    processing then a notification should be sent based on that task Subject
    Is this what you exactly meant or something else.
    plese clarify
    Thanks & Regards
    Hari Sankar M

  • How can I create sub-arrays based on the positions of indicies in a separate index array?

    Please forgive me if this question is basic or obvious. I am fairly new to LabVIEW and I'm trying to learn as I go along.
    I have a 1D array of index values (the number of possible index values is not fixed, but can vary between uses of the application; it could be just {0, 1} on one day and {1, 5, 11, 678} on another) and a 1D array of measurement values (doubles). I'd like to parse the measurement values into sub-arrays for each index, so that if my index array was:
    [0 1 1 1 1 5 5 0 5 5 1 0 1 1 5]
    and my measurement array was:
    [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.10 0.11 0.12 0.13 0.14 0.15]
    I would get back 3 sub-arrays:
    [0.1 0.8 0.12]
    [0.2 0.3 0.4 0.5 0.11 0.13 0.14]
    [0.6 0.7 0.9 0.10 0.15]
    I know there must be a simple way to do this, I guess I'm just stuck too much in matlab-array thinking to figure it out... please help!
    -- jph
    Solved!
    Go to Solution.

    jamespherman wrote:
    Thus, I figured it might be possible to generalize this idea and send multiple sets of XY values to an XY graph.
    OK, all we need is a trivial modification of what we already have. XY graph data is easiest handled using complex data. Here's a quick rewrite. See if this works for you.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SplitInGroupsGraph.vi ‏14 KB

  • How can I do a loop within a select statement

    This is my query
    Select distinct
    s.First_NM,
    s.Last_nm,
    s.Date_of_birth,
    i.Class_ID,
    i.Enrollment_begn_dt,
    i.Enrollment_end_dt,
    SUBSTR(TO_CHAR(i.Enrollment_begn_dt, 'MMDDYYYY'),1,2) AS MONTH,
    SUBSTR(TO_CHAR(i.Enrollment_end_dt, 'MMDDYYYY'),5,4) AS YEAR,
    CASE WHEN TO_NUMBER(SUBSTR(TO_CHAR(i.Enrollment_begn_dt, 'MMDDYYYY'),1,2)) >= '5'
          THEN (TO_NUMBER(SUBSTR(TO_CHAR(i.Enrollment_begn_dt,'MMDDYYYY'),5,4)) + '1')
           ELSE TO_NUMBER(SUBSTR(TO_CHAR(i.Enrollment_begn_dt,'MMDDYYYY'),5,4)) END AS Enrollment_cycle
    From student s, institution iEnrollment cycles are defined as follows
    05/1/2004 to 04/30/2005 == 2005
    05/1/2005 to 04/30/2006 == 2006
    05/1/2006 to 04/30/2007 == 2007
    05/1/2007 to 04/30/2008 == 2008
    This is the current output
    First_NM       Last_nm     Date_of_birth     Class_ID     Enrollment_begn_dt     Enrollment_end_dt     Enrollment_cycle
    Jake     Brown     11/10/1999     Blue_007         7/10/2004        6/10/2007        2005
    Amy     Burrell     5/1/1999                     Blue_007         1/20/2005        5/1/2005        2005
    Char     Goblin     12/24/1999     Blue_007         3/3/2006        7/10/2020        2006My desired output is - which I am having difficulty creating
    First_NM       Last_nm     Date_of_birth     Class_ID     Enrollment_begn_dt     Enrollment_end_dt     Enrollment_cycle
    Jake     Brown     11/10/1999     Blue_007         7/10/2004        4/30/2005       2005
    Jake     Brown     11/10/1999     Blue_007         5/1/2005        4/30/2006       2006
    Jake     Brown     11/10/1999     Blue_007         5/1/2006        4/30/2007       2007
    Jake     Brown     11/10/1999     Blue_007         5/1/2007        6/10/2007       2008
    Amy     Burrell     5/1/1999                     Blue_007         1/20/2005        5/1/2005       2005
    Char     Goblin     12/24/1999     Blue_007         3/3/2006        4/30/2006       2006
    Char     Goblin     12/24/1999     Blue_007         5/1/2006        4/30/2007       2007
    Char     Goblin     12/24/1999     Blue_007         5/1/2007        4/30/2008       2008
    Char     Goblin     12/24/1999     Blue_007         5/1/2008        4/30/2009       2009I trying to break up each record in the previous table into multiple enrollment cycles based on how it is decribed.
    Also note the last record - the cycle ends at 4/30/2009 ----This is because the enrollment_cycle will only stop at the current year + 1 (i.e if we assume current year to be 2008 then the cut off will be year will be 2009 hence I have 4/30/2009 instead of 7/10/2020
    I am thinking this can be done with a for loop but I am not sure how to do it. without hard coding the dates.
    Please help me!!!!!

    Hi ,
    I forgot the DATE_OF_BIRTH.
    Regards
    Salim.
    WITH t AS
         (SELECT 'Jake' first_nm, 'Brown' last_nm, to_date('11/10/1999','mm/dd/yyyy') date_of_birth,
                 'Blue_007' class_id, to_date('07/10/2004','mm/dd/yyyy') enrollment_begn_dt,
                 to_date('06/10/2007','mm/dd/yyyy') enrollment_end_dt, '2005' enrollment_cycle
            FROM DUAL
          UNION ALL
          SELECT 'Amy', 'Burrell', to_date('05/01/1999','mm/dd/yyyy'), 'Blue_007', to_date('01/20/2005','mm/dd/yyyy'),
                 to_date('05/01/2005','mm/dd/yyyy'), '2005' enrollment_cycle
            FROM DUAL
          UNION ALL
          SELECT 'Char', 'Goblin', to_date('12/24/1999','mm/dd/yyyy'), 'Blue_007', to_date('03/03/2006','mm/dd/yyyy'),
                 to_date('07/10/2020','mm/dd/yyyy'), '2006' enrollment_cycle
            FROM DUAL)
    SELECT FIRST_NM,LAST_NM,DATE_OF_BIRTH,ENROLLMENT_BEGN_DT,ENROLLMENT_END_DT,ENROLLMENT_CYCLE
      FROM T
      MODEL
      RETURN UPDATED ROWS
      PARTITION BY (FIRST_NM,LAST_NM)
      DIMENSION BY (1 ANNEE )
      MEASURES(ENROLLMENT_BEGN_DT,DATE_OF_BIRTH,ENROLLMENT_CYCLE,LEAST(  ENROLLMENT_END_DT, TRUNC(SYSDATE)) ENROLLMENT_END_DT)IGNORE NAV
      (  ENROLLMENT_BEGN_DT[FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT ( YEAR FROM ENROLLMENT_END_DT[1])   INCREMENT 1]  =  TO_DATE(TO_CHAR(ENROLLMENT_BEGN_DT[1],'MM/DD')||'/'||CV(ANNEE),'MM/DD/YYYY'),
         ENROLLMENT_END_DT [FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT ( YEAR FROM ENROLLMENT_END_DT[1])  INCREMENT 1]  =  TO_DATE('04/30'||(CASE WHEN EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) = 
                                                                                                                                                                                    EXTRACT ( YEAR FROM ENROLLMENT_END_DT[1])  THEN CV(ANNEE) ELSE CV(ANNEE)+1 END)  ,'MM/DD/YYYY'),
         ENROLLMENT_CYCLE [FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT ( YEAR FROM ENROLLMENT_END_DT[1])  INCREMENT 1] =CV(ANNEE) ,
         DATE_OF_BIRTH [FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT ( YEAR FROM ENROLLMENT_END_DT[1])  INCREMENT 1] =DATE_OF_BIRTH[1])
    SQL> WITH t AS
      2       (SELECT 'Jake' first_nm, 'Brown' last_nm, to_date('11/10/1999','mm/dd/yyyy') date_of_birth
      3               'Blue_007' class_id, to_date('07/10/2004','mm/dd/yyyy') enrollment_begn_dt,
      4               to_date('06/10/2007','mm/dd/yyyy') enrollment_end_dt, '2005' enrollment_cycle
      5          FROM DUAL
      6        UNION ALL
      7        SELECT 'Amy', 'Burrell', to_date('05/01/1999','mm/dd/yyyy'), 'Blue_007', to_date('01/20/2
    005','mm/dd/yyyy'),
      8               to_date('05/01/2005','mm/dd/yyyy'), '2005' enrollment_cycle
      9          FROM DUAL
    10        UNION ALL
    11        SELECT 'Char', 'Goblin', to_date('12/24/1999','mm/dd/yyyy'), 'Blue_007', to_date('03/03/2
    006','mm/dd/yyyy'),
    12               to_date('07/10/2020','mm/dd/yyyy'), '2006' enrollment_cycle
    13          FROM DUAL)
    14  SELECT FIRST_NM,LAST_NM,DATE_OF_BIRTH,ENROLLMENT_BEGN_DT,ENROLLMENT_END_DT,ENROLLMENT_CYCLE
    15    FROM T
    16    MODEL
    17    RETURN UPDATED ROWS
    18    PARTITION BY (FIRST_NM,LAST_NM)
    19    DIMENSION BY (1 ANNEE )
    20    MEASURES(ENROLLMENT_BEGN_DT,DATE_OF_BIRTH,ENROLLMENT_CYCLE,LEAST(  ENROLLMENT_END_DT, TRUNC(S
    YSDATE)) ENROLLMENT_END_DT)IGNORE NAV
    21    (  ENROLLMENT_BEGN_DT[FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT
    ( YEAR FROM ENROLLMENT_END_DT[1])   INCREMENT 1]  =  TO_DATE(TO_CHAR(ENROLLMENT_BEGN_DT[1],'MM/DD')
    ||'/'||CV(ANNEE),'MM/DD/YYYY'),
    22       ENROLLMENT_END_DT [FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT
    ( YEAR FROM ENROLLMENT_END_DT[1])  INCREMENT 1]  =  TO_DATE('04/30'||(CASE WHEN EXTRACT ( YEAR FROM
    ENROLLMENT_BEGN_DT[1]) = 
    23                                                                                                
                                                                                     EXTRACT ( YEAR FROM
    ENROLLMENT_END_DT[1])  THEN CV(ANNEE) ELSE CV(ANNEE)+1 END)  ,'MM/DD/YYYY'),
    24       ENROLLMENT_CYCLE [FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT
    ( YEAR FROM ENROLLMENT_END_DT[1])  INCREMENT 1] =CV(ANNEE) ,
    25       DATE_OF_BIRTH [FOR ANNEE FROM   EXTRACT ( YEAR FROM ENROLLMENT_BEGN_DT[1]) TO  EXTRACT ( Y
    EAR FROM ENROLLMENT_END_DT[1])  INCREMENT 1] =DATE_OF_BIRTH[1])
    26    ;
    FIRS LAST_NM DATE_OF_BI ENROLLMENT ENROLLMENT ENRO
    Jake Brown   1999-11-10 2004-07-10 2005-04-30 2004
    Jake Brown   1999-11-10 2005-07-10 2006-04-30 2005
    Jake Brown   1999-11-10 2006-07-10 2007-04-30 2006
    Jake Brown   1999-11-10 2007-07-10 2008-04-30 2007
    Amy  Burrell 1999-05-01 2005-01-20 2005-04-30 2005
    Char Goblin  1999-12-24 2006-03-03 2007-04-30 2006
    Char Goblin  1999-12-24 2007-03-03 2008-04-30 2007
    Char Goblin  1999-12-24 2008-03-03 2009-04-30 2008
    Char Goblin  1999-12-24 2009-03-03 2010-04-30 2009
    9 ligne(s) sélectionnée(s).

  • How can I create a sub-iTunes account for a teen?

    how can I create a sub-iTunes account for a teen?
    I need to separate our music libraries but still keep it under control from the main account (mine).

    iOS 5 & iCloud Tips: Sharing an Apple ID With Your Family

  • How can I create a sub-folder within my "Documents" folder?

    How can I create a sub-folder within my "Documents" folder? I have many similar documents that I want to group together. This will also un-clutter my Documents folder.

    Also, you can add a New Folder button to the Finder's toolbar by opening Finder, going to the View menu in the menubar, selecting Customize Toolbar..., and dragging the New Folder icon to the toolbar in the Finder window. Then it's just one-click for new folders wherever you want them.

  • How to create Sub Queries In Webi

    Hi,
    we are creating webi reports by using BICS connection..
    Now my requirement is how to create sub queries in webi.
    Any one give me suggestions how to achieve this
    Regards,
    G

    Hi Bhargav,
    Below is thread related to same topic-
    http://scn.sap.com/thread/3430274
    ~Anuj

  • How can I create an EntityStore for a Database?  Advice on DB strategy?

    Hello All,
    How can I create an com.sleepycat.persist.EntityStore for a com.sleepycat.db.Database? Advice on DB strategy?
    I'm looking to create an application prototype that creates a database dynamically and can delete it programatically. Is openDatabase/removeDatabase what I'd want to use for that?
    So far, the Direct Persistence Layer is an amazing piece of technology and has the potential to make my team's application faster than we every though possible, so kudos to the author.
    I've built a high-security application using the DPL and a single database for hundreds millions of users. I'd like to attempt to create a database for each user for security and manageability purposes. Our mission statement doesn't allow us to execute queries for sensitive data across more than one user account at a time, so I don't get any benefit from having every user's objects in a single database. I'm investigating if giving each user their own database will speed up insert times and SecondaryIndex queries. It'll certainly be more secure as each database will be encrypted with a unique password.
    My design is that I have an app with dozens of com.sleepycat.persist.model.Entity beans which I persist and query on their Primary and secondary indexes. I've been accessing things through an EntityStore as illustrated in the Getting Started Guide. Can I access a database created with openDatabase through an EntityStore and com.sleepycat.persist.PrimaryIndex?
    Thanks in Advance,
    Steven
    Harvard Childrens Hospital Informatics Program

    I closed this as I found another way to solve my issue.
    Thanks,
    Steven

  • How do I create sub-pages in iWeb?

    Hi, How do I create sub-pages in iweb like it does in this website
    http://www.e-alliance.ch/index.php?id=405
    with all the main menus "about us", "advocacy capacity", etc?
    Thank you for your help!!!
    Boaz

    To create sub pages, just ensure that the main menu item is in the main menu and then for the sub pages themselves, ensure that they are NOT in the main menu and you link back by creating links instead.
    For example, you could use Staff as a main menu item, so Staff would be in the main menu and then descriptions of different staff members would be underneath, but not in the main menu - they would have separate links that you create and then hyperlink.
    If you want to make drop down menus in iWeb, as in the site that you linked to, you can't do this directly in iWeb itself.  You have to make it and then upload various css files to your web host and link to it in iWeb etc.  It is quite a complex task to create drop down menus in iWeb.  If you want to do that, then I would suggest that you use a different app instead - take a look at http://www.everwebapp.com.

  • How can I create a drawing like the one pictured from a photo?

    How can I create a drawing like the one pictured from a photo?

    OK, you are getting closer. Now, use your result, and place a Layer above that. Use the Pen Tool to create the "pen strokes" basically tracing over your background image. Then, when you have created each Path (or Sub-Path), choose Stroke Path, with probably the Pencil Tool and a Brush size that is small enough.
    Not sure which versions of PS these are good for, but here are some plug-ins, that might be helpful.
    AKVIS Sketch
    EdgeLine
    Sketch Effects
    Sketch Master
    I see that one of my old favorites, Flaming Pear's India Ink is not around any more.
    Good luck,
    Hunt

  • How can I create additional "Sent Mail" folders so that I can organize my sent mail along the same lines as the inbox? I use Mail v 4.5

    How can I create additional or sub "Sent Mail" folders so that I can organize my sent mail along the same lines as the inbox? I use Mail v 4.5.

    Thank you for your reply Don, but I had already gone through that procedure and it will only create new mailboxes for received mail. I want to create new mailboxes for sent mail, i.e. the first column being "to" not "from". Under the Mailbox menus there is an option "Use This Mailbox For" but all the options under that (including Sent) are greyed out. Unfortunately the View/Columns option to change from "From" to "To" changes all mailboxes not just the active one.

  • How can u creat LSMW port in Idoc Processing

    how can u creat LSMW port in Idoc Processing
    actullay i'm using Lsmw with bapi

    Hello Ronei
                 *After giving the project ,sub project ,object & short description
                      *go to menu bar click on settings  in that select idoc inbound processing ,
                      *in that screen click on maintain port push button
                      *port creation screen will be displayed in that left menu expand the file
                      *after that select file_port
                      *click on copy button
                      *provide your port name
                      *provide the short description
                      *after that deselect the uni code check box
          --->*this is the main step
                     *in the directory you will provide the path of your flat file other wise your
                      project will be terminated after 13 th step .
    thanks .
    prasad gandepalli     

  • How can I create JScrollPane in my swing application with scroll bars movin

    Hi,
    How can we create scrollpanes moving with scrollbars.I tried many times with custom layout.but it does not work if i set custom layout.I hope that I will get my problem solved.
    Thanks and Regards,
    Rameh RK

    This means it is not possible to create a pure unicode file without the byte order mark?
    You wouldn't happen to know how a file with byte order mark should read on a Linux system?
    Or if this possible or not?
    Regards
    Christian

  • TS2756 How can i create a new usb connection (service)  on my iMac for sharing internet from my iPhone5 ( i seem have to deleted it )

    How can i create a new usb connection (service)  on my iMac for sharing internet from my iPhone5 ( i seem have to deleted it )
    i know its not a problem whit my carrier o data plan or sharing preferences on the ipone because when i use it un my laptop it works perfectly through
    the usb and even works on the Imac through wifi and bluethood tethering but NOT through usb!!.
    the problem is that trying to make it work i deleted the "profile" usb iphone on the network prefereces panel. Now i only have 3 options: ethernet / wifi / bluetooth
    but not the usb iPhone i used to have.
    And when i try to add a new one i dont get a USB option.
    can some one help me please??
    this is how it looks (after the bluetooth PAN i used to have USB iPhone option)

    The question would be more appropriate in the Mac forums as it is not really related to the iPhone.

Maybe you are looking for

  • IPod not recognized by windows after iTunes update

    After my iTunes 6.0 update, my computer (running on Windows XP) suddenly won't recognize my iPod. It says "Does not recognize USB device," and "no driver found". When I connect my iPod to my laptop (which still has iTunes 4.0 installed) it is recogni

  • Memory speed differs from chip

    I just purchased a used Mac Pro.  The specs are as follows: Dual 6 core 2.4GHz Xeon.  It came with 24 Gbs of memory but the model of the memory chip comes up in system report as: 1066MHz DDR3 ECC SDRAM.  I checked the specs of the model number, and I

  • How to analyse a problem in BI ( Example missing Data in a report )

    Hello; What is the best procedure to analyse a problem missing data in BW. the question could be unclear but I am looking for a method to determine directly and without taking long time in follwing the dataflow to be able to say that we have a proble

  • How to get Photoshop CC in French

    I'm a creative cloud member and just downloaded Photoshop CC, but is is in english, usually all my  soft are in french, how can I get it in french ? tks for the help

  • Can't turn off my ipod, just keeps spinning and clicking

    I have a 40GB click wheel ipod, about 1 year old. I just tried to update my playlist, but my computer couldn't recognise the ipod. I tried to reset it, but now all it says is "Disk mode, OK to disconnect", but the little hard drive keeps spinning and