Joining/Selection problem...

I have created this view:
- First it selects the Lowest and Highest date which should be taken in DATES
- Then it selects every first of the month between the Lowest and Highest date and stores that in MONTHS
- Then it selects the ID, FirstOfTheMonth, (intakes UP TO FirstOfTheMonth), (Outgoing UP TO FirstOfTheMonth) from TWO tables without matching any id field...
Now If I run the view in SQL Developer, it works nicely. If I use the view in Crystal Reports i get an error message saying a subquery returns more than 1 row...
I have a feeling that my CALCULATIONS table is wrongly setup. The problem is that I need to select the PNM_AUTO_KEY from Parts_master and use this Key in the two subqueries... The way i did that is probably wrong.... My guessing is I should use a OUTER JOIN in stead of the way I did it now...?_
CREATE OR REPLACE FORCE VIEW "VIEW_STOCK_COUNT" ("PNM_AUTO_KEY", "COUNT_DATE", "QTY_RECEIVED", "QTY_USED", "QTY_BALANCE") AS
with
DATES as
(select (select min(REC_DATE) from STOCK) as FROM_DT, (select max(CHANGE_DATE) from STOCK_ADJUST) as TO_DT from DUAL),
MONTHS as
(select add_months(trunc(FROM_DT,'MM'),ROWNUM-1) as DT from DATES connect by ROWNUM <= months_between(TO_DT, FROM_DT)+1),
CALCULATIONS as
(select
PNM.PNM_AUTO_KEY PNM_KEY,
MONTHS.DT DT,
NVL((select sum(stm.qty_rec) from stock stm WHERE STM.REC_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY GROUP BY pnm_auto_key),0) INCOMING,
NVL((select sum(saj.qty_adj) from stock_adjust saj
inner join stock stm on saj.stm_auto_key = stm.stm_auto_key
inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where SAJ.CHANGE_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY group by pnm_auto_key),0) OUTGOING
from MONTHS, PARTS_MASTER PNM)
SELECT
CALCULATIONS.PNM_KEY PNM_AUTO_KEY, CALCULATIONS.DT COUNT_DATE,CALCULATIONS.INCOMING QTY_RECEIVED, CALCULATIONS.OUTGOING QTY_USED, (CALCULATIONS.INCOMING + CALCULATIONS.OUTGOING) QTY_BALANCE
FROM
CALCULATIONS;

Hi,
user574699 wrote:
I have created this view:
- First it selects the Lowest and Highest date which should be taken in DATES
- Then it selects every first of the month between the Lowest and Highest date and stores that in MONTHS
- Then it selects the ID, FirstOfTheMonth, (intakes UP TO FirstOfTheMonth), (Outgoing UP TO FirstOfTheMonth) from TWO tables without matching any id field...
Now If I run the view in SQL Developer, it works nicely. If I use the view in Crystal Reports i get an error message saying a subquery returns more than 1 row...
Sorry, I don't know anything about Crystal Reports. I would expect the view to be handled entirely by the database. What is the query that you're running when you get the error?
Will Crystal Reports run a very simple query on this view?
I have a feeling that my CALCULATIONS table is wrongly setup. The problem is that I need to select the PNM_AUTO_KEY from Parts_master and use this Key in the two subqueries... The way i did that is probably wrong.... My guessing is I should use a OUTER JOIN in stead of the way I did it now...?_That's easy to test. Replace the scalar sub-queries with literals, and see if Crystal Reports will run it.
If not, that's not the problem.
If you do decide to re-write the calculations sub-query, and you need help, post some sample data and what calculations should contain given that data.
Could the WITH-clause be causing the problem? (Again, it's hard to see why the front-end tool would care how the view was defined.)
It looks like you could use in-line views instead of WITH, if necessary.
CREATE OR REPLACE FORCE VIEW "VIEW_STOCK_COUNT" ("PNM_AUTO_KEY", "COUNT_DATE", "QTY_RECEIVED", "QTY_USED", "QTY_BALANCE") AS
with
DATES as
(select (select min(REC_DATE) from STOCK) as FROM_DT, (select max(CHANGE_DATE) from STOCK_ADJUST) as TO_DT from DUAL),
MONTHS as
(select add_months(trunc(FROM_DT,'MM'),ROWNUM-1) as DT from DATES connect by ROWNUM <= months_between(TO_DT, FROM_DT)+1),
CALCULATIONS as
(select
PNM.PNM_AUTO_KEY PNM_KEY,
MONTHS.DT DT,
NVL((select sum(stm.qty_rec) from stock stm WHERE STM.REC_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY GROUP BY pnm_auto_key),0) INCOMING,
NVL((select sum(saj.qty_adj) from stock_adjust saj
inner join stock stm on saj.stm_auto_key = stm.stm_auto_key
inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where SAJ.CHANGE_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY group by pnm_auto_key),0) OUTGOING
from MONTHS, PARTS_MASTER PNM)
SELECT
CALCULATIONS.PNM_KEY PNM_AUTO_KEY, CALCULATIONS.DT COUNT_DATE,CALCULATIONS.INCOMING QTY_RECEIVED, CALCULATIONS.OUTGOING QTY_USED, (CALCULATIONS.INCOMING + CALCULATIONS.OUTGOING) QTY_BALANCE
FROM
CALCULATIONS;Don't post unformatted code

Similar Messages

  • Selection Problem with JTable

    Hello,
    i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
    I preffered the style from MS Outlook Express where you can select the email accounts to edit.
    It is a table like this:
    Account name  |   Type  |   ...
    --------------|---------|---------------------
    Hotmail       |   POP3  |
    GMX           |   IMAP  |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
    Please help me!
    Thanks.
    Warlock

    Maybe this will helpimport java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        String[] head = {"One", "Two"};
        String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
        JTable jt = new JTable(data, head);
        jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.setCellSelectionEnabled(true);
        jt.setRowSelectionAllowed(false);
        jt.setColumnSelectionAllowed(false);
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    class MyTableSelectionModel extends DefaultListSelectionModel {
      public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(0, 0);
    }

  • Select Problem For 'Back Menus' - Zen V P

    Just got the Zen V Plus and tried to set the time/date. Followed the 'guide' and after the time/date screen pressed the 'back button'. Got the Set Alarm/Date/Time (etc) menu but when I selected an option (moved joystick down to desired option then pressed the joystick) the time/date display came up and I was NOT ABLE to set the date. Same thing occurred trying to set the date (tried it several times and it worked once .... then attempted again - several times (4) but it only worked once). Turns out I have the same problem with any option in ANY 'back' menu. Suggestion?
    Do I have a defecti've unit (can't be the 'operator' who is defecti've! haha)? Should I return it and try another?
    Actually not that interested in playing music .... it's more for playing .wma(DRM) book files.

    Latest ... updated my firmware (to ZENVPlus_PCFW_P4S_L2___0.exe) and it fixed the select problem for SET DATE/TIME etc however
    the SELECT procedure doesn't always work for 'back button' menus. Example: tried to set a bookmark... following procedure in 'guide', pressed 'back button' and held it, from 'NOW PLAYING' screen - works 2 out of 5 times. Most of the time, pressing and holding takes you back to the previous menu - not to the 'back' (or in this case the SET BOOKMARK) menu. Sounds like something for the next version of firmware ... the code doesn't always set an internal timer correctly (am a programmer of 30 years ... part of that time pgmmng firmware).

  • Dynamic table name in an inner join - select statement

    Hi,
    Please can you let me know if is possible to use a Dynamic table name in an inner join?
    Something like the statement below? (It works in a simple select statement but not in an inner join)
    SELECT  *
         INTO CORRESPONDING FIELDS OF <t_itab>
          FROM <Dynamic table name> INNER JOIN pa0050 ON
          ( <Dynamic table name>pernr =  pa0050pernr )
           WHERE <Dynamic table name>~pernr = it_pernr-l_pernr
           AND pa0050~bdegr = f_bdegr.
    Any help would be apprecited very much.
    Thanks & Regards.

    Hi,
    Check this link.
    [http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/frameset.htm]
    [Re: accessing dynamic internal table's fields??;
    hope it'll help u.
    Regards,
    Sneha.
    Edited by: sneha kumari on Jun 18, 2009 1:57 PM

  • How to do outer join select query for an APEX report

    Hello everyone,
    I am Ann.
    I have one select statement that calculate the statistics for one month(October 2012 in this example)
    select ph.phase_number
    , sum ( (case
    WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(TO_DATE('Oct 2012','MON YYYY'))
    THEN last_day(TO_DATE('Oct 2012','MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    from phase_membership ph
    inner join court_engagement ce on ph.mpm_eng_id = ce.engagement_id
    inner join defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started <= last_day(TO_DATE('Oct 2012','MON YYYY'))
    and ph.active = 1
    and UPPER(ce.court_name) LIKE '%'
    group by rollup(phase_number)
    Result is as below
    Phase_Number     AVG_DAYS
    Phase One     8.6666666666666667
    Phase Two     14.6
    Phase Three     12
         11.4615365
    I have other select list mainly list the months between two date value.
    select to_char(which_month, 'MON YYYY') as display_month
    from (
    select add_months(to_date('Aug 2012','MON YYYY'), rownum-1) which_month
    from all_objects
    where
    rownum <= months_between(to_date('Oct 2012','MON YYYY'), add_months(to_date('Aug 2012','MON YYYY'), -1))
    order by which_month )
    Query result is as below
    DISPLAY_MONTH
    AUG 2012
    SEP 2012
    OCT 2012
    Is there any way that I can join these two select statement above to generate a result like:
    Month          Phase Number     Avg days
    Aug 2012     Phase One     8.666
    Sep 2012     Phase One     7.66
    Oct 2012     Phase One     5.66
    Aug 2012     Phase Two     8.666
    Sep 2012     Phase Two     7.66
    Oct 2012     Phase Two     5.66
    Aug 2012     Phase Three     8.666
    Sep 2012     Phase Three     7.66
    Oct 2012     Phase Three     5.66
    Or
    Month          Phase Number     Avg days
    Aug 2012     Phase One     8.666
    Aug 2012     Phase Two     7.66
    Aug 2012     Phase Three     5.66
    Sep 2012     Phase One     8.666
    Sep 2012     Phase Two     7.66
    Sep 2012     Phase Three     5.66
    Oct 2012     Phase One     8.666
    Oct 2012     Phase Two     7.66
    Oct 2012     Phase Three     5.66
    And it can be order by either Phase Number or Month.
    My other colleague suggest I should use an left outer join but after trying so many ways, I am still stuck.
    One of the select I tried is
    select a.display_month,b.* from (
    select to_char(which_month, 'MON YYYY') as display_month
    from (
    select add_months(to_date('Aug 2012','MON YYYY'), rownum-1) which_month
    from all_objects
    where
    rownum <= months_between(to_date('Oct 2012','MON YYYY'), add_months(to_date('Aug 2012','MON YYYY'), -1))
    order by which_month )) a left outer join
    ( select to_char(ph.date_finished,'MON YYYY') as join_month, ph.phase_number
    , sum ( (case
    WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(TO_DATE(a.display_month,'MON YYYY'))
    THEN last_day(TO_DATE(a.display_month,'MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    from phase_membership ph
    inner join court_engagement ce on ph.mpm_eng_id = ce.engagement_id
    inner join defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started <= last_day(TO_DATE(a.display_month,'MON YYYY'))
    and ph.active = 1
    and UPPER(ce.court_name) LIKE '%'
    group by to_char(ph.date_finished,'MON YYYY') , rollup(phase_number)) b
    on a.display_month = b.join_month
    but then I get an error
    SQL Error: ORA-00904: "A"."DISPLAY_MONTH": invalid identifier
    I need to display a report on APEX with option for people to download at least CSV format.
    I already have 1 inteactive report in the page, so don’t think can add another interactive report without using the iframe trick.
    If any of you have any ideas, please help.
    Thanks a lot.
    Ann

    First of all, a huge thanks for following this Frank.
    I have just started working here, I think the Oracle version is 11g, but not sure.
    To run Oracle APEX version 4, I think they must have at least 10g R2.
    This report is a bit challenging for me.I has never worked with PARTITION before.
    About the select query you suggested, I run , and it seems working fine, but if I try this,
    it return error ORA-01843: not a valid month
    DEFINE startmonth = "Aug 2012";
    DEFINE endmonth   = "Oct 2012";
    WITH     all_months     AS
         select add_months(to_date('&startmonth','MON YYYY'), rownum-1) AS which_month
         ,      add_months(to_date('&startmonth','MON YYYY'), rownum  ) AS next_month
         from all_objects
         where
         rownum <= months_between(to_date('&endmonth','MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1))
    select TO_CHAR (am.which_month, 'Mon YYYY')     AS month
    ,      ph.phase_number
    , sum ( (case
    WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(TO_DATE(am.which_month,'MON YYYY'))
    THEN last_day(TO_DATE(am.which_month,'MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    FROM           all_months          am
    LEFT OUTER JOIN  phase_membership  ph  PARTITION BY (ph.phase_number)
                                        ON  am.which_month <= ph.date_started
                               AND am.next_month  >  ph.date_started
                               AND ph.date_started <= last_day(TO_DATE(am.which_month,'MON YYYY'))  -- May not be needed
                               AND ph.active = 1
    LEFT OUTER join  court_engagement  ce  on  ph.mpm_eng_id = ce.engagement_id
                                        and ce.court_name IS NOT NULL  -- or something involving LIKE
    LEFT OUTER join  defendant         def on  ce.defendant_id = def.def_id
                                        AND def.active = 1
    group by rollup(phase_number, am.which_month)
    ORDER BY  am.which_month
    ,            ph.phase_number
    ;Here is the shorted versions of the three tables:
    A_DEFENDANT, A_ENGAGEMENT, A_PHASE_MEMBERSHIP
    CREATE TABLE "A_DEFENDANT"
        "DEF_ID"     NUMBER NOT NULL ENABLE,
        "FIRST_NAME" VARCHAR2(50 BYTE),
        "SURNAME"    VARCHAR2(20 BYTE) NOT NULL ENABLE,
        "DOB" DATE NOT NULL ENABLE,
        "ACTIVE" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        CONSTRAINT "A_DEFENDANT_PK" PRIMARY KEY ("DEF_ID"))
    Sample Data
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (101,'Joe','Bloggs',to_date('12/12/99','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (102,'John','Smith',to_date('20/05/00','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (103,'Jane','Black',to_date('15/02/98','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (104,'Minnie','Mouse',to_date('13/12/88','DD/MM/RR'),0);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (105,'Daisy','Duck',to_date('05/08/00','DD/MM/RR'),1);
    CREATE TABLE "A_ENGAGEMENT"
        "ENGAGEMENT_ID" NUMBER NOT NULL ENABLE,
        "COURT_NAME"    VARCHAR2(50 BYTE) NOT NULL ENABLE,
        "DATE_REFERRED" DATE,
        "DETERMINATION_HEARING_DATE" DATE,
        "DATE_JOINED_COURT" DATE,
        "DATE_TREATMENT_STARTED" DATE,
        "DATE_TERMINATED" DATE,
        "TERMINATION_TYPE" VARCHAR2(50 BYTE),
        "ACTIVE"           NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        "DEFENDANT_ID"     NUMBER,
        CONSTRAINT "A_ENGAGEMENT_PK" PRIMARY KEY ("ENGAGEMENT_ID"))
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (1,'AA',to_date('12/08/12','DD/MM/RR'),null,to_date('12/08/12','DD/MM/RR'),null,null,null,1,101);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (2,'BB',to_date('01/09/12','DD/MM/RR'),null,to_date('02/09/12','DD/MM/RR'),null,null,null,1,102);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (3,'AA',to_date('02/09/12','DD/MM/RR'),null,to_date('15/09/12','DD/MM/RR'),null,null,null,1,103);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (4,'BB',to_date('01/10/12','DD/MM/RR'),null,to_date('02/10/12','DD/MM/RR'),null,null,null,1,105);
    CREATE TABLE "A_PHASE_MEMBERSHIP"
        "MPM_ID"       NUMBER NOT NULL ENABLE,
        "MPM_ENG_ID"   NUMBER NOT NULL ENABLE,
        "PHASE_NUMBER" VARCHAR2(50 BYTE),
        "DATE_STARTED" DATE NOT NULL ENABLE,
        "DATE_FINISHED" DATE,
        "NOTES"  VARCHAR2(2000 BYTE),
        "ACTIVE" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        CONSTRAINT "A_PHASE_MEMBERSHIP_PK" PRIMARY KEY ("MPM_ID"))
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (1,1,'PHASE ONE',to_date('15/09/12','DD/MM/RR'),to_date('20/09/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (2,1,'PHASE TWO',to_date('21/09/12','DD/MM/RR'),to_date('29/09/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (3,2,'PHASE ONE',to_date('12/09/12','DD/MM/RR'),null,null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (4,3,'PHASE ONE',to_date('20/09/12','DD/MM/RR'),to_date('01/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (5,3,'PHASE TWO',to_date('02/10/12','DD/MM/RR'),to_date('15/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (6,4,'PHASE ONE',to_date('03/10/12','DD/MM/RR'),to_date('10/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (7,3,'PHASE THREE',to_date('17/10/12','DD/MM/RR'),null,null,0);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (8,1,'PHASE THREE',to_date('30/09/12','DD/MM/RR'),to_date('16/10/12','DD/MM/RR'),null,1);
    The requirements are:
    The user must be able to request the extract for one or more calendar months, e.g.
    May 2013
    May 2013 – Sep 2013.
    The file must contain a separate row for each calendar month in the requested range. Each row must contain the statistics computed for that calendar month.
    The file must also include a row of totals.
    The user must be able to request the extract for either Waitakere or Auckland or Consolidated (both courts’ statistics accumulated).
    Then the part that I am stuck is
    For each monitoring phase:
    Phase name (e.g. “Phase One”)
    Avg_time_in_phase_all_particip
    for each phase name,
    Add up days in each “phase name” Monitoring Phase, calculated as:
    If Monitoring Phase.Date Finished is NULL or > month end date,
    +(*Month end date* Minus Monitoring Phase.Date Started Plus 1)+
    Otherwise (phase is complete)
    +(Monitoring Phase.Date Finished Minus Monitoring Phase.Date Started Plus 1.)+
    Divide by the numbers of all participants who have engaged in “phase name”.
    This is the words of the Business Analyst,
    I try to do as required but still struggle to identify end_month for the above formula to display for the range of months.
    Of course, I can write two nested cursor. The first one run the list of month, then for each month, run the parameterised report.
    But I prefer if possible just use SQL statements, or at least a PL/SQL but return a query.
    With this way, I can create an APEX report, and use their CSV Extract function.
    Yes, you are right, court_name is one of the selection parameters.
    And the statistics is not exactly for one month. It is kind of trying to identify all phases that are running through the specified month (even phase.date_started is before the month start).
    This is the reason why I put the condition AND ph.date_started <= last_day(TO_DATE('Oct 2012','MON YYYY')) (otherwise I get negative avg_days)
    User can choose either one court "AA" or "BB" or combined which is all figures.
    Sorry for bombarding you a lot of information.
    Thanks a lot, again.
    Edited by: Ann586341 on Oct 29, 2012 9:57 PM
    Edited by: Ann586341 on Oct 29, 2012 9:59 PM

  • Print selection problem

    when i select a page to be print from my pc the page select in

    Hello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
    Click on Safari
    Scroll down to services then slide to right
    Scroll down to services preferences and click
    Scroll down to the Text section
    If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
    BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
    Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
    I really hope that helps with your problem
    I can now go to sleep.

  • Inner join-select -primary key in table issue

    Hi ,
            Iam using FEBKO(header) and FEBEP(item) in inner join  select .But the datas fetching by this selct in not correct.The analysis is the is no common primary fields in the both table.
    Question 1-> Can i use inner join without common primary key in the both tables, weather it possible to make a select without common primary key in both table. Please kindly let me know.
    Question 2-> What is the other possible way to give the selct for both table(better performance)
    Regards,
    Veera

    Hi,
    When you use INNER JOIN in this case, link your tables based on KUKEY and ESNUM fields, bcoz there can be many items under a single header. So this will work for you, even from the performance point of view.
    Hope this is helpful to you. If you need further information, revert back.
    Reward all the helpful answers.
    Regards
    Nagaraj T

  • At Line selection problem

    hi,
    iam stuck up with AT LINE-SELECTION problem ie i designed a screen where they need month list on clicking F4. i got the month list using month_names_get in the screen but while clicking the relevant month no.it's not entering into the required parameter. i have attached the codings,
    MODULE MONTH_DIS OUTPUT.
      SUPPRESS DIALOG.
      LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
      SET PF-STATUS SPACE.
      NEW-PAGE NO-TITLE.
      WRITE:/ 'SELECT MONTH' COLOR COL_HEADING.
      ULINE.
      DATA: T_MNTH LIKE T247 OCCURS 12 WITH HEADER LINE.
      refresh t_mnth.
      CALL FUNCTION 'MONTH_NAMES_GET'
       EXPORTING
         LANGUAGE                    = SY-LANGU
    IMPORTING
      RETURN_CODE                 =
        TABLES
          MONTH_NAMES                 = T_MNTH
       EXCEPTIONS
         MONTH_NAMES_NOT_FOUND       = 1
         OTHERS                      = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      loop at t_mnth.
        write:/ t_mnth-mnr, t_mnth-ltx.
      endloop.
      CLEAR T_MNTH-MNR.
    ENDMODULE.                 " MONTH_DIS  OUTPUT
    AT LINE-SELECTION.
      p_period = t_mnth-mnr.
      CHECK NOT p_period IS INITIAL.
      LEAVE TO SCREEN 0.
    here in the AT LINE-SELECTION, the selected month is not coming to the required parameter.
    pls help me in this issue,
    Thanks in advance,
    Premnath.

    You need to set a "Hide" after the write... I suggest you also set your own dialog PF-STATUS too so you can have just a PF2 "pick" button and a Cancel button ( this will look better to the user).
    loop at t_mnth.
      write:/ t_mnth-mnr, t_mnth-ltx.
      hide: t_mnth.  "needs this
    endloop.
    clear: t_mnth.

  • Weird BGP path selection problem

    Hi, all,
    I am seeing a weird BGP path selection problem on 4948 switch running cat4500-entservicesk9-mz.122-46.SG.bin code, this switch has two uplinks to the same ISP's different edge router, one circuit is primary the other one is strict backup, only default route is accepted from ISP. I am setting both local preference and weight to the default route advertised over backup link, however neither one is taking effect, BGP still thinks the backup link is better, what could be wrong?
    rtr#sh ip bgp 0.0.0.0/0
    BGP routing table entry for 0.0.0.0/0, version 105
    Paths: (3 available, best #2, table Default-IP-Routing-Table, not advertised to EBGP peer)
      Not advertised to any peer
      17675, (received & used)
        203.169.8.37 from 203.169.8.37 (61.211.160.150)
          Origin IGP, localpref 100, valid, external
          Community: 65001:0 no-export
      17675
        203.169.8.45 from 203.169.8.45 (61.211.160.151)
          Origin IGP, localpref 90, weight 90, valid, external, best <====
          Community: 65001:0 no-export
      17675, (received-only)
        203.169.8.45 from 203.169.8.45 (61.211.160.151)
          Origin IGP, localpref 100, valid, external
          Community: 65001:0 no-export
    Thanks

    Hi,
    On cisco routers , weight is having highest preference to decide best path. By default for received route, weight is 0 but you are setting weight 90 to backup path and that is why it is getting preferred (higher is better). Please remove weight and let local preference be 90 (lesser than route on primary path)
    --Pls dont forget to rate helpful posts--
    Regards,
    Akash

  • Join Selectivity

    Hello,
    Below is an extract of a 10053 trace file for a test case, I am trying to understand a join selectivity value of 0.200781 when joining TABLE_2 to TABLE_3 my understanding of the join selectivity formula is:
    Join Selectivity = greater(num_distinct(t1.c1),num_distinct(t2.c2) - Assuming no nulls.
    However in the example below this does not appear to be case in this situation, I am just trying to understand the behaviour therfore any suggestions would be appreciated.
    Database is 11gR2
    QUERY BLOCK TEXT
    select x1.x ,count(*)
    from table_3 x3
    join table_2 x2 on x2.x = x3.x
    join table_1 x1 on x1.x = x2.x
    where x1.x=1
    group by x1.x
    QUERY BLOCK SIGNATURE
    signature (optimizer): qb_name=SEL$9E43CB6E nbfros=3 flg=0
    fro(0): flg=0 objn=688324 hint_alias="X2"@"SEL$1"
    fro(1): flg=0 objn=688325 hint_alias="X3"@"SEL$1"
    fro(2): flg=0 objn=688323 hint_alias="X1"@"SEL$2"
    SYSTEM STATISTICS INFORMATION
    Using WORKLOAD Stats
    CPUSPEED: 500 millions instructions/sec
    SREADTIM: 10.000000 milliseconds
    MREADTIM: 20.000000 millisecons
    MBRC: 16 blocks
    MAXTHR: -1 bytes/sec
    SLAVETHR: -1 bytes/sec
    BASE STATISTICAL INFORMATION
    Table Stats::
    Table: TABLE_1 Alias: X1
    #Rows: 4 #Blks: 60 AvgRowLen: 2.00 ChainCnt: 0.00
    Column (#1): X(
    AvgLen: 2 NDV: 4 Nulls: 0 Density: 0.250000
    Table Stats::
    Table: TABLE_2 Alias: X2
    #Rows: 20 #Blks: 60 AvgRowLen: 2.00 ChainCnt: 0.00
    Column (#1): X(
    AvgLen: 2 NDV: 8 Nulls: 0 Density: 0.025000
    Histogram: Freq #Bkts: 8 UncompBkts: 20 EndPtVals: 8
    Table Stats::
    Table: TABLE_3 Alias: X3
    #Rows: 80 #Blks: 60 AvgRowLen: 2.00 ChainCnt: 0.00
    Column (#1): X(
    AvgLen: 2 NDV: 9 Nulls: 0 Density: 0.012500
    Histogram: HtBal #Bkts: 80 UncompBkts: 80 EndPtVals: 9
    Access path analysis for TABLE_3
    SINGLE TABLE ACCESS PATH
    Single Table Cardinality Estimation for TABLE_3[X3]
    Table: TABLE_3 Alias: X3
    Card: Original: 80.000000 Rounded: 80 Computed: 80.00 Non Adjusted: 80.00
    Access Path: TableScan
    Cost: 9.09 Resp: 9.09 Degree: 0
    Cost_io: 9.00 Cost_cpu: 439286
    Resp_io: 9.00 Resp_cpu: 439286
    Best:: AccessPath: TableScan
    Cost: 9.09 Degree: 1 Resp: 9.09 Card: 80.00 Bytes: 0
    Access path analysis for TABLE_2
    SINGLE TABLE ACCESS PATH
    Single Table Cardinality Estimation for TABLE_2[X2]
    Table: TABLE_2 Alias: X2
    Card: Original: 20.000000 Rounded: 20 Computed: 20.00 Non Adjusted: 20.00
    Access Path: TableScan
    Cost: 9.09 Resp: 9.09 Degree: 0
    Cost_io: 9.00 Cost_cpu: 430286
    Resp_io: 9.00 Resp_cpu: 430286
    Best:: AccessPath: TableScan
    Cost: 9.09 Degree: 1 Resp: 9.09 Card: 20.00 Bytes: 0
    Access path analysis for TABLE_1
    SINGLE TABLE ACCESS PATH
    Single Table Cardinality Estimation for TABLE_1[X1]
    Table: TABLE_1 Alias: X1
    Card: Original: 4.000000 Rounded: 1 Computed: 1.00 Non Adjusted: 1.00
    Access Path: TableScan
    Cost: 9.09 Resp: 9.09 Degree: 0
    Cost_io: 9.00 Cost_cpu: 428486
    Resp_io: 9.00 Resp_cpu: 428486
    Best:: AccessPath: TableScan
    Cost: 9.09 Degree: 1 Resp: 9.09 Card: 1.00 Bytes: 0
    Grouping column cardinality [         X] 1
    OPTIMIZER STATISTICS AND COMPUTATIONS
    GENERAL PLANS
    Considering cardinality-based initial join order.
    Permutations for Starting Table :0
    Join order[1]: TABLE_1[X1]#0 TABLE_2[X2]#1 TABLE_3[X3]#2
    Now joining: TABLE_2[X2]#1
    NL Join
    Outer table: Card: 1.00 Cost: 9.09 Resp: 9.09 Degree: 1 Bytes: 2
    Access path analysis for TABLE_2
    Inner table: TABLE_2 Alias: X2
    Access Path: TableScan
    NL Join: Cost: 18.17 Resp: 18.17 Degree: 1
    Cost_io: 18.00 Cost_cpu: 858773
    Resp_io: 18.00 Resp_cpu: 858773
    Best NL cost: 18.17
    resc: 18.17 resc_io: 18.00 resc_cpu: 858773
    resp: 18.17 resp_io: 18.00 resc_cpu: 858773
    Join Card: 2.500000 = = outer (1.000000) * inner (20.000000) * sel (0.125000)
    Join Card - Rounded: 3 Computed: 2.50
    Grouping column cardinality [         X] 1
    Outer table: TABLE_1 Alias: X1
    resc: 9.09 card 1.00 bytes: 2 deg: 1 resp: 9.09
    Inner table: TABLE_2 Alias: X2
    resc: 9.09 card: 20.00 bytes: 2 deg: 1 resp: 9.09
    using dmeth: 2 #groups: 1
    SORT ressource Sort statistics
    Sort width: 598 Area size: 536576 Max Area size: 104857600
    Degree: 1
    Blocks to Sort: 1 Row size: 13 Total Rows: 1
    Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
    Total IO sort cost: 0 Total CPU sort cost: 5000000
    Total Temp space used: 0
    SORT ressource Sort statistics
    Sort width: 598 Area size: 536576 Max Area size: 104857600
    Degree: 1
    Blocks to Sort: 1 Row size: 13 Total Rows: 20
    Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
    Total IO sort cost: 0 Total CPU sort cost: 5003894
    Total Temp space used: 0
    SM join: Resc: 20.17 Resp: 20.17 [multiMatchCost=0.00]
    SM Join
    SM cost: 20.17
    resc: 20.17 resc_io: 18.00 resc_cpu: 10862667
    resp: 20.17 resp_io: 18.00 resp_cpu: 10862667
    Outer table: TABLE_1 Alias: X1
    resc: 9.09 card 1.00 bytes: 2 deg: 1 resp: 9.09
    Inner table: TABLE_2 Alias: X2
    resc: 9.09 card: 20.00 bytes: 2 deg: 1 resp: 9.09
    using dmeth: 2 #groups: 1
    Cost per ptn: 0.50 #ptns: 1
    hash_area: 131 (max=25600) buildfrag: 1 probefrag: 1 ppasses: 1
    Hash join: Resc: 18.67 Resp: 18.67 [multiMatchCost=0.00]
    HA Join
    HA cost: 18.67
    resc: 18.67 resc_io: 18.00 resc_cpu: 3360923
    resp: 18.67 resp_io: 18.00 resp_cpu: 3360923
    Best:: JoinMethod: Hash
    Cost: 18.67 Degree: 1 Resp: 18.67 Card: 2.50 Bytes: 4
    Now joining: TABLE_3[X3]#2
    NL Join
    Outer table: Card: 2.50 Cost: 18.67 Resp: 18.67 Degree: 1 Bytes: 4
    Access path analysis for TABLE_3
    Inner table: TABLE_3 Alias: X3
    Access Path: TableScan
    NL Join: Cost: 42.94 Resp: 42.94 Degree: 1
    Cost_io: 42.00 Cost_cpu: 4678782
    Resp_io: 42.00 Resp_cpu: 4678782
    Best NL cost: 42.94
    resc: 42.94 resc_io: 42.00 resc_cpu: 4678782
    resp: 42.94 resp_io: 42.00 resc_cpu: 4678782
    Join Card: 40.156250 = = outer (2.500000) * inner (80.000000) * sel (0.200781)
    Join Card - Rounded: 40 Computed: 40.16
    Grouping column cardinality [         X] 1
    Outer table: TABLE_2 Alias: X2
    resc: 18.67 card 2.50 bytes: 4 deg: 1 resp: 18.67
    Inner table: TABLE_3 Alias: X3
    resc: 9.09 card: 80.00 bytes: 2 deg: 1 resp: 9.09
    using dmeth: 2 #groups: 1
    SORT ressource Sort statistics
    Sort width: 598 Area size: 536576 Max Area size: 104857600
    Degree: 1
    Blocks to Sort: 1 Row size: 15 Total Rows: 3
    Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
    Total IO sort cost: 0 Total CPU sort cost: 5000214
    Total Temp space used: 0
    SORT ressource Sort statistics
    Sort width: 598 Area size: 536576 Max Area size: 104857600
    Degree: 1
    Blocks to Sort: 1 Row size: 13 Total Rows: 80
    Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
    Total IO sort cost: 0 Total CPU sort cost: 5022787
    Total Temp space used: 0
    SM join: Resc: 29.76 Resp: 29.76 [multiMatchCost=0.00]
    SM Join
    SM cost: 29.76
    resc: 29.76 resc_io: 27.00 resc_cpu: 13823210
    resp: 29.76 resp_io: 27.00 resp_cpu: 13823210
    Outer table: TABLE_2 Alias: X2
    resc: 18.67 card 2.50 bytes: 4 deg: 1 resp: 18.67
    Inner table: TABLE_3 Alias: X3
    resc: 9.09 card: 80.00 bytes: 2 deg: 1 resp: 9.09
    using dmeth: 2 #groups: 1
    Cost per ptn: 0.50 #ptns: 1
    hash_area: 131 (max=25600) buildfrag: 1 probefrag: 1 ppasses: 1
    Hash join: Resc: 28.26 Resp: 28.26 [multiMatchCost=0.00]
    HA Join
    HA cost: 28.26
    resc: 28.26 resc_io: 27.00 resc_cpu: 6308659
    resp: 28.26 resp_io: 27.00 resp_cpu: 6308659
    GROUP BY sort
    GROUP BY adjustment factor: 1.000000
    GROUP BY cardinality: 1.000000, TABLE cardinality: 40.000000
    SORT ressource Sort statistics
    Sort width: 598 Area size: 536576 Max Area size: 104857600
    Degree: 1
    Blocks to Sort: 1 Row size: 17 Total Rows: 40
    Initial runs: 1 Merge passes: 0 IO Cost / pass: 0
    Total IO sort cost: 0 Total CPU sort cost: 5009591
    Total Temp space used: 0
    Best:: JoinMethod: Hash
    Cost: 29.26 Degree: 1 Resp: 29.26 Card: 40.16 Bytes: 6
    Best so far: Table#: 0 cost: 9.0857 card: 1.0000 bytes: 2
    Table#: 1 cost: 18.6722 card: 2.5000 bytes: 12
    Table#: 2 cost: 29.2637 card: 40.1562 bytes: 240
    ***********************

    When transitive closure is applied, wouldn't this be evident from a) the predicates section of the execution plan (not supplied) and b) an adjustment in the computed cardinality in the SINGLE TABLE ACCESS PATH section, as seen for TABLE_1:
    Access path analysis for TABLE_1
    SINGLE TABLE ACCESS PATH
    Single Table Cardinality Estimation for TABLE_1[X1]
    Table: TABLE_1 Alias: X1
    Card: Original: 4.000000 Rounded: 1 Computed: 1.00 Non Adjusted: 1.00Edited by: Dom Brooks on Jul 19, 2011 3:56 PM

  • Certificate selection problem in Safari

    Hi ,
    I have certifcates A,B,C,D for the same site , whenever i use the Mozilla it is asking which one to select , but somehow i dont know why Safari is asking the same option.
    It is forcing me to accept Certifcate A to that paricular site. How to solve this problem in safari.
    Regards
    Vikranth

    Hello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
    Click on Safari
    Scroll down to services then slide to right
    Scroll down to services preferences and click
    Scroll down to the Text section
    If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
    BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
    Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
    I really hope that helps with your problem
    I can now go to sleep.

  • New airport: can't get my macbook or my imac to join my wireless automatically, my other stuff still joins without problems but i have to join manually with the book and the imac ?? I've tried all the settings and every thing else I can think of.....

    new airport: can't get my macbook or my imac to join my wireless automatically, my other stuff still joins without problems but i have to join manually with the book and the imac ?? I've tried all the settings and every thing else I can think of.....
    Running on Lion, never had a problem before until the old airport died and I replaced it.

    try connecting the device in _*recovery mode*_, then restore from your backup.
    also, make sure [_*Apple Mobile Device Service*_|http://support.apple.com/kb/TS1567] is installed and started.
    JGG

  • Select Problem with Joined tables

    Hello everyone I have the following Query
    SELECT
        OBJEKTI.OBJEKAT_ID OBJEKAT_ID,
        OBJEKTI.ADRESA ADRESA,
        OBJEKTI.POVRSINA POVRSINA,
        OBJEKTI.BROJ_IZVRSILACA BROJ_IZVRSILACA,
        OPREMLJENOSTI.OPREMLJENOST_ID OPREMLJENOST_ID,
        OPREMLJENOSTI.PULT PULT,
        OPREMLJENOSTI.REKLAMA REKLAMA,
        OPREMLJENOSTI.MOKRI_CVOR MOKRI_CVOR,
        OPREMLJENOSTI.WC_ZA_IGRACE WC_ZA_IGRACE,
        OPREMLJENOSTI.WC_ZA_OSOBLJE WC_ZA_OSOBLJE,
        OPREMLJENOSTI.VENTILATOR VENTILATOR,
        OPREMLJENOSTI.OSVJETLJENJE OSVJETLJENJE,
        OPREMLJENOSTI.VRSTA_BROJILA VRSTA_BROJILA,
        OPREMLJENOSTI.ELEKTRO_INSTALACIJE ELEKTRO_INSTALACIJE,
        OPREMLJENOSTI.VODO_INSTALACIJE VODO_INSTALACIJE,
        OPREMLJENOSTI.TELEFONSKE_INSTALACIJE TELEFONSKE_INSTALACIJE,
        OPREMLJENOSTI.GRIJANJE_ID GRIJANJE_ID,
        OPREMLJENOSTI.POD_ID POD_ID,
        OPREMLJENOSTI.PROZORI_VRATA_ID PROZORI_VRATA_ID,
        OPREMLJENOSTI.OBJEKAT_ID OBJEKAT_ID1,
        TEHNICKE_OPREMLJENOSTI.TEH_OPR_ID TEH_OPR_ID,
        TEHNICKE_OPREMLJENOSTI.ONLINE_KLADIONICA ONLINE_KLADIONICA,
        TEHNICKE_OPREMLJENOSTI.PANO PANO,
        TEHNICKE_OPREMLJENOSTI.NOSACI NOSACI,
        TEHNICKE_OPREMLJENOSTI.TV_LCD TV_LCD,
        TEHNICKE_OPREMLJENOSTI.TV_TELETEXT TV_TELETEXT,
        TEHNICKE_OPREMLJENOSTI.APARATI_IGRE APARATI_IGRE,
        TEHNICKE_OPREMLJENOSTI.EVONA EVONA,
        TEHNICKE_OPREMLJENOSTI.NOVOMATIC NOVOMATIC,
        TEHNICKE_OPREMLJENOSTI.RULET RULET,
        TEHNICKE_OPREMLJENOSTI.BILIJAR BILIJAR,
        TEHNICKE_OPREMLJENOSTI.KLIMA KLIMA,
        TEHNICKE_OPREMLJENOSTI.OBJEKAT_ID OBJEKAT_ID2,
        PONUDE.PONUDA_ID PONUDA_ID,
        PONUDE.ONLINE_TERMINAL ONLINE_TERMINAL,
        PONUDE.SRECKE SRECKE,
        PONUDE.ONLINE_KLADIONICA ONLINE_KLADIONICA1,
        PONUDE.APARATI_IGRE APARATI_IGRE1,
        PONUDE.RULET RULET1,
        PONUDE.BILIJAR BILIJAR1,
        PONUDE.OBJEKAT_ID OBJEKAT_ID3
    FROM
        OBJEKTI,
        OPREMLJENOSTI,
        TEHNICKE_OPREMLJENOSTI,
        PONUDE
    WHERE
    (PONUDE.OBJEKAT_ID=OBJEKTI.OBJEKAT_ID AND TEHNICKE_OPREMLJENOSTI.OBJEKAT_ID=OPREMLJENOSTI.OBJEKAT_ID) OR (OPREMLJENOSTI.OBJEKAT_ID=OBJEKTI.OBJEKAT_ID AND TEHNICKE_OPREMLJENOSTI.OBJEKAT_ID=OPREMLJENOSTI.OBJEKAT_ID)
    ORDER BY OBJEKTI.OBJEKAT_IDThe problem I get is no matter what WHERE clause I use I get doubled values which makes no sense. I checked in the tables and I don't have any doubled values. Each Opremljenost has 1 objekat (there are 2 rows each with its own Objekat) and the same applies to the other 2 tables (PONUDE and TEHNICKE OPREMLJENOSTI) but for some reason they double up the values. If I run it without a where clause at all I get some values repeat itself up to 4 times. Does anyone have a clue what is wrong with my query?

    You are joining a parent table (OBJEKTI) with three child tables (the other three: PON, TEH, OPR).
    Whenever you do that, you will always get duplication of child-rows, if there are multiple child-rows for a parent-row in any of the three child tables.
    For example, let P be a parent table, with two child tables, say C1 and C2.
    Contents:
    Table P:
    p1
    Table C1 (has two rows for row p1):
    1 p1
    2 p1
    Table C2 (has three rows for row p1):
    10 p1
    20 p1
    30 p1If you now do this:
    select P.*,C1.*,C2.*
    from P, C1, C2
    where [join P with C1]  and [join P with C2]Then your result set will look like this:
    P.p1  C1.1  C1.p1  C2.10  C2.p1
    P.p1  C1.1  C1.p1  C2.20  C2.p1
    P.p1  C1.1  C1.p1  C2.30  C2.p1
    P.p1  C1.2  C1.p1  C2.10  C2.p1
    P.p1  C1.2  C1.p1  C2.20  C2.p1
    P.p1  C1.2  C1.p1  C2.30  C2.p1As you can see every C1 row is duplicated three times in the resultset (due to join with C2).
    And every C2 row is duplicated two times in the resultset (due to join with C1).
    This is simply what happens if you join a parent table with multiple child tables...
    Question now is: what is the expected result that you are looking for?

  • Joining select statements-performance problem

    Here two cases are there.Is it posiible to combine the two cases and make it one? I am using OR in the select statement, performance is very bad, i want to improve it.Is there any chance of avoiding that...
    1.
    select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1
    or vbelv = final_data-xblnr2.
    select single vbeln from vbrk into tabvbrk-vbeln
    where vbeln = itab-vbeln and fkart = 'RTS'.
    if sy-subrc eq 0.
    move tabvbrk-vbeln to final_data-vbeln1.
    modify final_data.
    endif.
    endselect.
    2.
    select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1
    or vbelv = final_data-xblnr2.
    select single vbeln from vbrk into tabvbrk-vbeln
    where vbeln = itab-vbeln and fkart = 'ZTR'.
    if sy-subrc eq 0.
    move tabvbrk-vbeln to final_data-vbeln2.
    modify final_data.
    endif.
    endselect.
    Thanks,
    fractal

    The first main thing is dont use select... endselect.
    select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1
    or vbelv = final_data-xblnr2.
    U can use
    select vbeln from vbfa into
    corresponding fields of table itab
    for all entries in final_data
    where vbelv = final_data-xblnr1
    or   vbelv = final_data-xblnr2.
    Instead of this
    select single vbeln from vbrk into tabvbrk-vbeln
    where vbeln = itab-vbeln and fkart = 'RTS'.
    if sy-subrc eq 0.
    move tabvbrk-vbeln to final_data-vbeln1.
    modify final_data.
    endif.
    endselect.
    Use
    select vbeln from vbrk
            appending table final_data
            where vbeln = itab-vbeln
            and fkart = 'RTS'.
    if sy-subrc eq 0.
    endif.
    Try like this.
    Hope this helps.
    Kindly reward points for the answer which helped u and helped to solve the problem.

  • Selection Problem in SAP B1 Query Manager

    Experts,
    select T0.DocNum 'AR Invoice Number',
    T0.DocDate 'AR Invoice Date',
    T0.CardCode,
    T0.CardName,
    T0.NumAtCard 'Vendor Ref No',
    (select sum (T1.Quantity * T1.Price) from INV1 T1 where T1.DocEntry = T0.DocEntry) 'Base Amount',
    ISNULL ((select sum (T3.TaxSum) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='1'), 0)'VAT Amount',
    ISNULL ((select MAX (T3.TaxRate) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='1'), 0)'VAT %',
    ISNULL ((select sum (T3.TaxSum) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='4'), 0)'CST Amount',
    ISNULL ((select MAX (T3.TaxRate) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='4'), 0)'CST %',
    ISNULL ((select sum (T3.TaxSum) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='5'), 0)'Service Amount',
    ISNULL ((select MAX (T3.TaxRate) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='5'), 0)'Service %',
    T0.TotalExpns 'Freight Amount',
    T0.WTSum 'TDS Amount',
    T0.DocTotal 'Document Total'
    from OINV T0
    where T0.DocDate >= '[%0]'
    and T0.DocDate <= '[%1]'
    When I run this query in SBO query maanger, it gives error for the selection criterias.
    1). [Microsoft][SQL Native Client][SQL Server]Must specify table to select from. 2). [Microsoft][SQL Native Client][SQL Server]Statement 'User-Defined Values' (CSHS) (s) could not be prepared.
    Please hlp

    Hi Rahul,
    I have just added credit memo with the query as per need, but same problem it shows!
    SELECT T0.[DocNum] 'AR Invoice #',
    T0.[DocDate] 'Date',
    T0.CardName 'Customer Name',
    T0.NumAtCard As 'Customer Ref',
    T0.[CardName], 
    Sum(T1.LineTotal) 'Base Amount',
    T0.[DocTotal] As 'Total Value',
    (isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxSum else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) 'VAT_Amt',
    (isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxRate else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'VAT%',
    (isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxSum else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'CST_Amt',
    (isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxRate else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'CST%',
    (isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxSum else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'Service_Amt',
    (isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxRate else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'Service%',
    T0.TotalExpns 'Freight Amount',
    T0.WTSum 'TDS Amount',
    T0.DocTotal 'Grand Total'
    FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    WHERE T0.DocDate>='[%0]' And T0.DocDate<='[%1]'
    Group By T0.[DocNum], T0.[DocDate], T0.NumAtCard, T0.[CardName], T0.[DocTotal] , T0.TotalExpns, T0.WTSum, T0.DocEntry,
    T0.WTSum,
    T0.TotalExpns
    Union All
    SELECT T0.[DocNum] 'AR Invoice #',
    T0.[DocDate] 'Date',
    T0.CardName 'Customer Name',
    T0.NumAtCard As 'Customer Ref',
    T0.[CardName], 
    -Sum(T1.LineTotal) 'Base Amount',
    -T0.[DocTotal] As 'Total Value',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxSum else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) 'VAT_Amt',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxRate else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'VAT%',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxSum else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'CST_Amt',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxRate else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'CST%',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxSum else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'Service_Amt',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxRate else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'Service%',
    -T0.TotalExpns 'Freight Amount',
    -T0.WTSum 'TDS Amount',
    -T0.DocTotal 'Grand Total'
    FROM ORIN T0  INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
    WHERE T0.DocDate>='[%0]' And T0.DocDate<='[%1]'
    Group By T0.[DocNum], T0.[DocDate], T0.NumAtCard, T0.[CardName], T0.[DocTotal] , T0.TotalExpns, T0.WTSum, T0.DocEntry,
    T0.WTSum,
    T0.TotalExpns
    Plz hlp

Maybe you are looking for