Col-to-Rows needed for MINUS later

Query 1
SCOTT@orcl>SELECT CUST_NAME, DOD_PROD_CODE, to_char(DOD_DOH_NO,999999) DOD_DOH_no,
  2  to_char(DOH_SO_REF_NO,999999) DOH_SO_REF_NO
  3  FROM DELIVERY_ORDER_HEADER, DELIVERY_ORDER_DETAIL, CUSTOMER_MASTER
  4  WHERE DOH_NO = DOD_DOH_NO
  5  AND DOH_PARTY_CODE = CUST_CODE
  6  AND DOH_SO_REF_NO = 13
  7  ORDER BY 2;
CUST_N DOD_PROD_CODE   DOD_DOH DOH_SO_
ENERGY P01033691.1          11      13
ENERGY P01033691.5          11      13
ENERGY P01033691.5          12      13
ENERGY P01033691.7          11      13
ENERGY P01033691.7          12      13
ENERGY P01033691.8          12      13
ENERGY P0140000014          11      13
ENERGY P01400012            11      13
8 rows selected.Query 2
SCOTT@orcl>SELECT CUST_NAME, SALEVD_PROD_CODE, SALEVH_DO_REF_NO,
  2  to_char(SALEVH_SO_REF_NO,999999) SALEVH_SO_REF_NO
  3  FROM SALES_INVOICE_HEADER, SALES_INVOICE_DETAIL,CUSTOMER_MASTER
  4  WHERE SALEVH_NO = SALEVD_SALEVH_NO
  5  AND SALEVH_PARTY_CODE = CUST_CODE
  6  AND SALEVH_SO_REF_NO = 13
  7  ORDER BY 2;
CUST_N SALEVD_PROD_COD SALEVH_DO_ SALEVH_
ENERGY P01033691.1     11,12           13
ENERGY P01033691.5     11,12           13
ENERGY P01033691.7     11,12           13
ENERGY P01033691.8     11,12           13
ENERGY P0140000014     11,12           13
ENERGY P01400012       11,12           13
6 rows selected.i want Query No.2 to be exactly returning the same number of rows, like Query No.1 - 8 Rows.
for example, in Query 1, there are 2 rows returned for product code P01033691.5 & P01033691.7,
whereas in Query 2 they are shown on single rows.
This is not the only case, the situaton may change where there can be more than 2 or just 1 values (in this case 11,12)
for SALEVH_DO_REF_NO Col. in Query 2.
i want to always break Col-to-Rows for Query 2,
based on the DOD_PROD_CODE & DOD_DOH_NO of Query 1 matching with SALEVD_PROD_CODE, SALEVH_DO_REF_NO of Query 2 .
so that it will become easier finally to use MINUS between both Queries like this;
Query 3
SELECT CUST_NAME, DOD_PROD_CODE, to_char(DOD_DOH_NO,999999) DOD_DOH_no,
to_char(DOH_SO_REF_NO,999999) DOH_SO_REF_NO
FROM DELIVERY_ORDER_HEADER, DELIVERY_ORDER_DETAIL, CUSTOMER_MASTER
WHERE DOH_NO = DOD_DOH_NO
AND DOH_PARTY_CODE = CUST_CODE
AND DOH_SO_REF_NO = 13
MINUS
SELECT CUST_NAME, SALEVD_PROD_CODE, SALEVH_DO_REF_NO,
to_char(SALEVH_SO_REF_NO,999999) SALEVH_SO_REF_NO
FROM SALES_INVOICE_HEADER, SALES_INVOICE_DETAIL,CUSTOMER_MASTER
WHERE SALEVH_NO = SALEVD_SALEVH_NO
AND SALEVH_PARTY_CODE = CUST_CODE
AND SALEVH_SO_REF_NO = 13as per the above data the Query3 should not return any rows, but lets say a row gets added to Query 1 result,
i mean a new DOD_DOH_NO for the same DOH_SO_REF_NO. a 9th row for example;
ENERGY P01400012 13 13
and theres is no Invoice done, then Query 3 should return just 1 row which is just the above 1, the 9th row.
any help will be highly appreciated. TY

Mr. Massimo,
Your Query MUST return rows and those should be the following 8 rows;
CUST_NAME  SALEVD_PROD_COD SALEVH_ SALEVH_
ENERGY     P01033691.1          11      13
ENERGY     P01033691.5          11      13
ENERGY     P01033691.7          11      13
ENERGY     P01400012            11      13
ENERGY     P0140000014          11      13
ENERGY     P01033691.5          12      13
ENERGY     P01033691.7          12      13
ENERGY     P01033691.8          12      13
8 rows selected.
Your Latest Query returned no rows at all;
SCOTT@orcl>SELECT CUST_NAME, DOD_PROD_CODE, to_char(DOD_DOH_NO,999999) DOD_DOH_no,
  2  to_char(DOH_SO_REF_NO,999999) DOH_SO_REF_NO
  3  FROM DELIVERY_ORDER_HEADER doh, DELIVERY_ORDER_DETAIL dod, CUSTOMER_MASTER c
  4  WHERE DOH_NO = DOD_DOH_NO
  5  AND DOH_PARTY_CODE = CUST_CODE
  6  AND 0 = (select count(0) FROM SALES_INVOICE_HEADER, SALES_INVOICE_DETAIL,CUSTOMER_MASTER c2
  7  WHERE SALEVH_NO = SALEVD_SALEVH_NO
  8  AND SALEVH_PARTY_CODE = CUST_CODE
  9  AND SALEVH_SO_REF_NO = DOH_SO_REF_NO
10  AND c2.CUST_NAME=c.CUST_NAME
11  AND SALEVD_PROD_CODE = DOD_PROD_CODE
12  AND regexp_like(SALEVH_DO_REF_NO ,'(^|,)'||to_char(DOD_DOH_NO,999999)||'(,|$)')
13  AND to_char(SALEVH_SO_REF_NO,999999) = to_char(DOH_SO_REF_NO,999999))
14  AND 0 < (select count(0) FROM SALES_INVOICE_HEADER, SALES_INVOICE_DETAIL
15  WHERE SALEVH_NO = SALEVD_SALEVH_NO
16  AND SALEVH_SO_REF_NO = DOH_SO_REF_NO
17  AND regexp_like(SALEVH_DO_REF_NO ,'(^|,)'||to_char(DOD_DOH_NO,999999)||'(,|$)'));
no rows selectedi will rephrase and putting my case again. i am sure this time you;ll have better grasp on it.
These are the records for Items actually Delivered,columns are;
Customer Name        = CUST_NAME     
Item Code            = DOD_PROD_CODE 
Deliver Order No.    = DOD_DOH_NO     (NUMBER)
Sales Order Ref. No. = DOH_SO_REF_NO 
SELECT CUST_NAME, DOD_PROD_CODE, to_char(DOD_DOH_NO,999999) DOD_DOH_no,
to_char(DOH_SO_REF_NO,999999) DOH_SO_REF_NO,DOD_QTY_DISPATCHED
FROM DELIVERY_ORDER_HEADER, DELIVERY_ORDER_DETAIL, CUSTOMER_MASTER
WHERE DOH_NO = DOD_DOH_NO
AND DOH_PARTY_CODE = CUST_CODE
ORDER BY 3;
CUST_NAME  DOD_PROD_CODE   DOD_DOH DOH_SO_ DOD_QTY_DISPATCHED
TOPAZ      P01400034             9      14                  4
TOPAZ      P01025299.5           9      14                  8
TOPAZ      P01025299.7           9      14                 15
TOPAZ      P0140000010           9      14                  2
TOPAZ      P01025299.2           9      14                 10
TOPAZ      P01025299.9           9      14                 10
TOPAZ      P01025299.3           9      14                 10
ENERGY     P01033691.1          11      13                  2
ENERGY     P01033691.5          11      13                  4
ENERGY     P01033691.5          12      13                  4
ENERGY     P01033691.7          11      13                  5
ENERGY     P01033691.7          12      13                  5
ENERGY     P01033691.8          12      13                  5
ENERGY     P01400012            11      13                  3
ENERGY     P0140000014          11      13                 10
ENERGY     P01033691.7          13      13                  2
ENERGY     P01033691.8          13      13                  5
17 rows selected.
Query No. 2
The following are the Invoice issued for the Items Delivered above.
Not all Invoices have been issued, still left, are for DOD_DOH_NO 9 & 13.
The columns are ;
Customer Name                 = CUST_NAME        
Item Code                     = SALEVD_PROD_CODE 
Invoice Deliver Order Ref.No. = SALEVH_DO_REF_NO  (VARCHAR2)
Sales Order Ref. No.          = SALEVH_SO_REF_NO 
SELECT SUBSTR(CUST_NAME,9,6) CUST_NAME, SALEVD_PROD_CODE, SALEVH_DO_REF_NO,
to_char(SALEVH_SO_REF_NO,999999) SALEVH_SO_REF_NO
FROM SALES_INVOICE_HEADER, SALES_INVOICE_DETAIL,CUSTOMER_MASTER
WHERE SALEVH_NO = SALEVD_SALEVH_NO
AND SALEVH_PARTY_CODE = CUST_CODE;
CUST_N SALEVD_PROD_COD SALEVH_DO_ SALEVH_ SALEVD_QTY
ENERGY P01033691.1     11,12           13          2
ENERGY P01033691.5     11,12           13          8
ENERGY P01033691.7     11,12           13         10
ENERGY P01033691.8     11,12           13          5
ENERGY P01400012       11,12           13          3
ENERGY P0140000014     11,12           13         10
6 rows selected.
Note: SALEVH_DO_REF_NO is VARCHAR2 field, that i have used save DOD_DOH_NO (type NUMBER) values,
in comma separated manner, offering user to club more than 1 Delivery Orders on a single Invoice.
Therefore i want a query that will turn Query2 result to something like;
CUST_NAME  SALEVD_PROD_COD SALEVH_ SALEVH_
ENERGY     P01033691.1          11      13
ENERGY     P01033691.5          11      13
ENERGY     P01033691.7          11      13
ENERGY     P01400012            11      13
ENERGY     P0140000014          11      13
ENERGY     P01033691.5          12      13
ENERGY     P01033691.7          12      13
ENERGY     P01033691.8          12      13
8 rows selected.

Similar Messages

  • As a new user of apple TV, I need some advice. When I rent a movie from Itunes for viewing later, it seems to download for a second time, with a message saying ready to view in 30 mins, it proceeds to load up all over again. What am I doing wrong

    As a new user of Apple TV, I need some assistance.When I rent a movie on iTunes and download for viewing later, say a day or two later, It seems to load itself all over again with a msg saying ready to view in 25 mins ! So having waited the 25 mins movie starts and runs for maybe 1 hour and the pauses for maybe 5 mins while it seems to load again . any help appreciated

    Welcome to the Apple Community.
    If you use the Apple TV for something else or turn it off it will erase whatever is on it's drive. If you are going to download content for later viewing you might consider doing it on the computer, downloads don't disappear until they expire and you can watch them as many times as you want.

  • How do I upgrade the plugins needed for my earlier version of InDesign CS5 so I can open a file in a later version of CS5?

    How do I upgrade the plugins needed for my earlier version of InDesign CS5 so I can open a file in a later version of CS5?

    You can’t. You have upgrade or have whoever is send you files save as IDML. Don’t expect perfection.

  • OUTGOING PAYMENT ROW INFORMATION WHERE IS IT STORED.  NEED FOR A REPORT

    OUTGOING PAYMENT ROW INFORMATION WHERE IS IT STORED.  NEED FOR A REPORT

    Try this thread:
    Query for outgoing payment
    Thanks,
    Gordon

  • I'm in need of a rubberized case for a late 2007 macbook pro 15.4 silver keys help please

    please help me out I'm in need of a rubberized case for a late 2007 macbook pro 15.4 (silver keys) cd in front.  Please help me out.  here is my personal email: *****@gmail.com I also have just purchased a 2006 macbook pro 17 inch and would like a case for that one too if anyone can help I would greatly appreciate it. 
    again here is my email:  ******@gmail.com
    thank you
    john
    <Edited by Host>

    John, please refrain from posting your personal email in these threads.  It is not necesary and all communication to you can be done directly in these forums.  Posting your email address can open up you to tons of unwanted spam, among other things.  Really all you can do is search the internet for them.  My suggestion would be to google "case for late 2007 macbook pro".
    One will probably be very hard to find for a 6 year old model as it is on the borderline of being considered "vintage".  Ebay may be a good place to try too.

  • I need a recommendation for a 24" monitor for my late 2013 MacBook Pro

    I need a recommendation for a 24" professional photography monitor for my late 2013 MacBook Pro.  I am looking for a monitor that plays well with my 13" late 2013 Macbook pro.  I tryed the Dell U2413 and found after the fact that it did not work well with my Macbook pro.  Read up on the Asus PA 249Q, It also seems to have problems with my Macbook Pro.  Apple display is larger than i want.  Looking for recommendations for compatable IPS monitor for use with Aperture. buget is $300 to $800.
    Anybody happy with thiers?
    MacBook Pro with Retina display, OS X Mavericks (10.9), Aperture 3.5.1

    Any monitor will work. Decide what specs work best for your needs and get that monitor.

  • What kind of wireless card I need for my Power Mac G5 (late 2005) Dual 2 GH

    hi there,
    I have for sometime now a "Power Mac G5 (late 2005) Dual 2 GHz PowerPC G5", and recently I have been thinking to get an Airport extreme wireless card with a bluetooth on it, which could work on my machine.
    I have already try to deal with apple representatives and Apple sales people to give me a hand on the matter and so far is been a nightmare to approach this guys, tired of wasting time and effort, so that is way I am posting a topic on this section to see if you guys could give a hand on the matter.
    All what I would like to know is what kind of wireless card I need for my Power Mac G5 (late 2005) Dual 2 GHz PowerPC G5 (version 10.4.11) and where I could buy one on line to install myself.
    This is the mac unit I have.
    Dual 2 GHz PowerPC G5.
    Hardware Overview:
    Machine Name: Power Mac G5
    Machine Model: PowerMac11,2
    CPU Type: PowerPC G5 (1.1)
    Number Of CPUs: 2
    CPU Speed: 2 GHz
    L2 Cache (per CPU): 1 MB
    Memory: 4.5 GB
    Bus Speed: 1 GHz
    Boot ROM Version: 5.2.7f1
    Thanks for you time.
    regards
    Toyko koyko

    You're welcome. Funny how Apple works isn't it? If it's any consolation, that Airport/Bluetooth card doesn't show up on the Apple U.S. store either. I don't think they ever intended it to be a user installable part, so perhaps that's why they don't offer it for sale. Do you have any Apple Authorized Service providers in your area? I'd think they'd be able to order the card as a replacement part.
    Can you give a little more detail or a link to the gadget you're referring to? It sounds like a USB dongle to enable Wi-Fi, but that must be a third party solution, since I don't believe Apple ever offered something like that.

  • Hide row values for certain column in GRR2

    Hi Experts,
    Looking for some help in report painter. I need to hide row values for certain columns in report painter. The requirement is I have 5 columns in the report, the 5 th column is the sum of col 1 to 4 and in my row i have a formula setup to sum of values for each column, what i would like to do is for column 1 thru 4 i didnt want to display the total values in row total but i wanted to dispaly value for column 5 in row total. I have been trying my best with putting formula, but couldnt succeed.
    Could somebody let me know is there an way to get this addressed.
    Thanks in advance
    Best Regards,
    gj

    How was it achieved ? Did you use sections for the columns for which rows needed to be hidden?
    I have a smiliar issue of hiding certain rows for few columns.

  • Where can I buy a larger hard drive for my late 2008, 15" macbook pro?  From reviewing questions and answers on the support community it would appear that having Apple remove the old and install the new hard drive is recommended.  But how/where?

    Where can I buy a larger hard drive for my late 2008, 15" macbook pro?  From reviewing questions and answers on the support community it would appear that having Apple remove the old and install the new hard drive is recommended.  But how/where?

    Welcome to Apple Support Communities
    You can install the new hard disk yourself if you want to. You just need a 2'5" SATA II hard drive, which is compatible with your MacBook Pro. You can buy one at OWC > http://eshop.macsales.com/shop/hard-drives/2.5-Notebook/ You can filter hard drives by computer, so press a "Click to view all...", choose your computer in the sidebar and it will give you the compatible hard drives.
    There are different brands for the MacBook Pro. The most recommended are HGST and Seagate, which have good reputation. A 7200 rpm hard drive will give you extra performance

  • Help needed for writing query

    help needed for writing query
    i have the following tables(with data) as mentioned below
    FK*-foregin key (SUBJECTS)
    FK**-foregin key (COMBINATION)
    1)SUBJECTS(table name)     
    SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
    2           02           Computer Science
    3           03           Physics
    4           04           Chemistry
    5           05           Mathematics
    7           07           Commerce
    8           08           Computer Applications
    9           09           Biology
    2)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
    383           S1      9           4           2           3
    384           S2      4           2           5           3
    ---------I actually designed the ABOVE table also like this
    3) a)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
    383           S1
    384           S2
    b)COMBINATION_DET
    COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
    1               383          9
    2               383          4
    3               383          2
    4               383          3
    5               384          4
    6               384          2          
    7               384          5
    8               384          3
    Business rule: a combination consists of a maximum of 4 subjects (must contain)
    and the user is less relevant to a COMB_NAME(name of combinations) but user need
    the subjects contained in combinations
    i need the following output
    COMB_ID COMB_NAME SUBJECT1 SUBJECT2      SUBJECT3      SUBJECT4
    383     S1     Biology Chemistry      Computer Science Physics
    384     S2     Chemistry Computer Science Mathematics Physics
    or even this is enough(what i actually needed)
    COMB_ID     subjects
    383           Biology,Chemistry,Computer Science,Physics
    384           Chemistry,Computer Science,Mathematics,Physics
    you can use any of the COMBINATION table(either (2) or (3))
    and i want to know
    1)which design is good in this case
    (i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
    good method to link with same table but if 4 subjects only(and must) comes
    detail table is not neccessary )
    now i am achieving the result by program-coding in C# after getting the rows from oracle
    i am using oracle 9i (also ODP.NET)
    i want to know how can i get the result in the stored procedure itsef.
    2)how it could be designed in any other way.
    any help/suggestion is welcome
    thanks for your time --Pradeesh

    Well I forgot the table-alias, here now with:
    SELECT C.COMB_ID
    , C.COMB_NAME
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
    FROM COMBINATION C;
    As you need exactly 4 subjects, the columns-solution is just fine I would say.

  • XMLAGG structure, performance help needed for odd nesting in schema

    Hello,
    I have to produce XML to look like:
    <?xml version='1.0'?>
      <enterprise>
        <membership>
          <sourcedid>
            <id>PHYS_101_001_FA2007</id>
          </sourcedid>
        <!-- NOTE: absence of "members" level tag for XMLAGG! -->
        <member>
          <sourcedid>
            <id>D2LU0001</id>
          </sourcedid>
          <role roletype="Sample Role">
            <status>1</status>
          </role>
        </member>
        <member>
          <sourcedid>
            <id>D2LU0002</id>
          </sourcedid>
          <role roletype="Sample Role">
            <status>1</status>
          </role>
        </member>
      </membership>
    </enterprise>This would be straightforward if the schema allowed for a "<members>" tag under which to nest the <member> tags. But, it does not allow for that tag or any other than those listed above.
    I have a query which does produce that output (except for the roletype attribute), but its performance is horrible; it takes about 40 minutes to return data:
    SELECT
         XMLROOT(
             XMLELEMENT("enterprise",
               XMLAGG(
                 XMLELEMENT("membership",
                   XMLFOREST( XMLELEMENT("id",cx.mapped_course_id) as "sourcedid"
                   (SELECT XMLAGG(
                     XMLELEMENT("member",
                       XMLFOREST(XMLELEMENT("id",spriden_id) AS "sourcedid",
                                 XMLELEMENT("status",'1') AS "role"
                      FROM enrollments_fall_sfrstca efs
                         , spriden sp
                         , gzv_tuid t
                     WHERE sp.spriden_change_ind IS NULL
                       AND sp.spriden_pidm       = t.pidm
                       AND t.tuid                = efs.user_name
                       AND efs.mapped_course_id  = cx.mapped_course_id
                       AND efs.term              = cx.semester
                , VERSION '1.0', STANDALONE NO VALUE)
      FROM courses_xt cx
    WHERE cx.semester = :term_code
    ;Similar queries are producing courses and users XML fine with no performance issues, but these are driven off either the courses view or the enrollments view, but not both.
    Is there some other way I can produce the nesting I need for the vendor's schema?
    The source views are basically as follows (showing relevant columns only):
    courses_xt:
    MAPPED_COURSE_ID       SEMEST
    AVFT209-13307-201210   201210
    AVFT210-13308-201210   201210enrollments_fall_sfrstca:
    MAPPED_COURSE_ID       USER_NAME
    AVFT209-13307-201210    FULLERC8
    AVFT209-13307-201210    SHUPEK
    AVFT209-13307-201210    NOMAN
    AVFT210-13308-201210    SHUPEK
    AVFT210-13308-201210    PELLONMWhen I have the query without the XML (with the subquery as a column of the outer query), this returns the correct data quickly (a couple of minutes).
    I have tried various permutations of XMLFOREST, XMLELEMENT, XMLAGG but either I get syntax errors, or the data is wrong (e.g. repeated '<membership>' for each '<member>', or I have to create an invalid tag '<members>' to be filtered later).
    Please advise!
    Thanks,
    Anita Lees

    Hi Anita,
    Have you tried with a GROUP BY and no subquery?
    Here's an example using SCOTT schema.
    I've used the same tag names and structure so that you can see the analogy :
    SELECT XMLElement("enterprise",
             XMLAgg(
               XMLElement("membership",
                 XMLElement("sourceid", xmlelement("id", d.deptno))
               , XMLAgg(
                   XMLElement("member",
                     XMLElement("sourceid",
                       XMLElement("id", e.empno)
                   , XMLElement("role",
                       XMLAttributes(e.job as "roletype")
                     , XMLElement("status", '1')
    FROM scott.dept d
         LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno
    WHERE d.deptno IN (10,20)
    GROUP BY d.deptno
    ;which gives :
    <enterprise>
      <membership>
        <sourceid>
          <id>10</id>
        </sourceid>
        <member>
          <sourceid>
            <id>7782</id>
          </sourceid>
          <role roletype="MANAGER">
            <status>1</status>
          </role>
        </member>
        <member>
          <sourceid>
            <id>7934</id>
          </sourceid>
          <role roletype="CLERK">
            <status>1</status>
          </role>
        </member>
        <member>
          <sourceid>
            <id>7839</id>
          </sourceid>
          <role roletype="PRESIDENT">
            <status>1</status>
          </role>
        </member>
      </membership>
      <membership>
        <sourceid>
          <id>20</id>
        </sourceid>
        <member>
          <sourceid>
            <id>7369</id>
          </sourceid>
          <role roletype="CLERK">
            <status>1</status>
          </role>
        </member>
        <member>
          <sourceid>
            <id>7902</id>
          </sourceid>
          <role roletype="ANALYST">
            <status>1</status>
          </role>
        </member>
        <member>
          <sourceid>
            <id>7566</id>
          </sourceid>
          <role roletype="MANAGER">
            <status>1</status>
          </role>
        </member>
      </membership>
    </enterprise>

  • How can I get null values for the later weeks

    Hi All,
    When I execute this code I get the records till current week.
    How can I display the output so that I get null values for the later weeks. (with the help of v_numOfWeeks variable in the code)
    Thanks,
    Vikram
    DECLARE
       v_query VARCHAR2(4000);
       TYPE ref_cursor IS REF CURSOR;
       v_refcur ref_cursor;
       v_sum NUMBER;
       v_id NUMBER;
       v_name VARCHAR2(1000);
       v_weeknum NUMBER;
       v_pernum NUMBER;
       v_numOfWeeks NUMBER := 5;
    BEGIN
    v_query := ' SELECT SUM(product_bkg), postn_id, postn_tbl.postn_name, b.week_num, b.period_num
                              FROM ops_cv_extract b, (SELECT row_id, desc_text postn_name
                          FROM s_postn) postn_tbl
                          WHERE lvl_6_id = 5767
                          AND fiscal_year = 2008
                          AND b.week_num < 4
                          AND b.period_num = 3
                          AND b.postn_id = TO_NUMBER(postn_tbl.row_id)
                          GROUP BY postn_id, postn_tbl.postn_name, b.week_num, b.period_num
                          ORDER BY  postn_tbl.postn_name, b.week_num';
    OPEN v_refcur FOR v_query;
    LOOP
       FETCH v_refcur INTO v_sum, v_id, v_name, v_weeknum, v_pernum;
       EXIT WHEN v_refcur%notfound;
       dbms_output.put_line('P'|| v_pernum||'W'|| v_weeknum||' '||v_name||' '||v_sum);
    END LOOP;
    END;
    This is the output when I execute this code.
    P3W1 COMM CNTRL ISAM 213 26961.61
    P3W2 COMM CNTRL ISAM 213 12870.4
    P3W3 COMM CNTRL ISAM 213 245.88
    P3W1 COMM CNTRL ISAM 273 72831.2
    P3W2 COMM CNTRL ISAM 273 8739.38
    P3W3 COMM CNTRL ISAM 273 3764.92
    P3W1 COMM CNTRL TAM 213 49844
    P3W2 COMM CNTRL TAM 213 20515.17
    P3W3 COMM CNTRL TAM 213 16167.46
    P3W2 COMM CNTRL TAM 216 12561.4
    P3W3 COMM CNTRL TAM 216 2027.1
    P3W1 COMM CNTRL TAM 273 -3336.71
    P3W2 COMM CNTRL TAM 273 -1376.68
    P3W3 COMM CNTRL TAM 273 19707.42
    P3W1 Damon Walters -609.07
    P3W2 Damon Walters 30030.24
    P3W3 Damon Walters 37475.1
    This is the output I'd like to get
    P3W1 COMM CNTRL ISAM 213 26961.61
    P3W2 COMM CNTRL ISAM 213 12870.4
    P3W3 COMM CNTRL ISAM 213 245.88
    P3W4 COMM CNTRL ISAM 213
    P3W5 COMM CNTRL ISAM 213
    P3W1 COMM CNTRL ISAM 273 72831.2
    P3W2 COMM CNTRL ISAM 273 8739.38
    P3W3 COMM CNTRL ISAM 273 3764.92
    P3W4 COMM CNTRL ISAM 273
    P3W5 COMM CNTRL ISAM 273
    P3W1 COMM CNTRL TAM 213 49844
    P3W2 COMM CNTRL TAM 213 20515.17
    P3W3 COMM CNTRL TAM 213 16167.46
    P3W4 COMM CNTRL TAM 213
    P3W5 COMM CNTRL TAM 213
    P3W1 COMM CNTRL TAM 273 -3336.71
    P3W2 COMM CNTRL TAM 273 -1376.68
    P3W3 COMM CNTRL TAM 273 19707.42
    P3W4 COMM CNTRL TAM 273
    P3W5 COMM CNTRL TAM 273
    P3W1 Damon Walters -609.07
    P3W2 Damon Walters 30030.24
    P3W3 Damon Walters 37475.1
    P3W4 Damon Walters
    P3W5 Damon Walters Edited by: polasa on Oct 28, 2008 6:42 PM

    Sure, in a Single SQL ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>-- Start Of Test Data --
    satyaki>with week_tab
      2  as
      3    (
      4      select 1 period_num, 1 week_num, 10 bkg1 from dual
      5      union all
      6      select 1, 2, 40 from dual
      7      union all
      8      select 1, 3, 30 from dual
      9      union all
    10      select 1, 2, 20 from dual
    11      union all
    12      select 1, 1, 10 from dual
    13      union all
    14      select 1, 1, 20 from dual
    15      union all
    16      select 1, 3, 10 from dual
    17      union all
    18      select 2, 1, 15 from dual
    19      union all
    20      select 2, 2, 20 from dual
    21      union all
    22      select 2, 3, 10 from dual
    23      union all
    24      select 2, 1, 15 from dual
    25      union all
    26      select 2, 2, 30 from dual
    27      union all
    28      select 2, 3, 20 from dual
    29    )
    30  -- End Of Test Data --
    31  select period_num,
    32         week_num,
    33         (
    34            select sum(week_tab.bkg1)
    35            from week_tab
    36            where period_num = m.period_num
    37            and   week_num   = m.week_num
    38            group by week_num, period_num
    39         ) sum_bkg1
    40  from (
    41        select dum.week_num,
    42              wk.period_num
    43        from (
    44                select 1 week_num from dual
    45                union all
    46                select 2 from dual
    47                union all
    48                select 3 from dual
    49                union all
    50                select 4 from dual
    51                union all
    52                select 5 from dual
    53              ) dum ,
    54              (
    55                select distinct period_num
    56                from week_tab
    57          ) wk
    58      ) m;
    PERIOD_NUM   WEEK_NUM   SUM_BKG1
             1          1         40
             1          2         60
             1          3         40
             1          4
             1          5
             2          1         30
             2          2         50
             2          3         30
             2          4
             2          5
    10 rows selected.
    Elapsed: 00:00:00.48
    satyaki>Regards.
    Satyaki De.

  • Hi have just purchased iphone 4s . my itunes on my mac is currently 10.4 . 10.5 is needed for the new iphone but when i download it and click on install the itunes about still says 10.4 . have tried to update through itunes but it says there is no softwar

    hi have just purchased iphone 4s . my itunes on my mac is currently 10.4 . 10.5 is needed for the new iphone but when i download it and click on install the itunes about still says 10.4 . have tried to update through itunes but it says there is no software available for me . please help . mr frustrated

    If your computer is running an OS X prior to Snow Leopard 10.6,
    the answer (if it is an Intel-based Mac; not old PowerPC model)
    would be to buy the retail Snow Leopard 10.6 DVD from Apple
    for about $20, and install it. Then update that to 10.6.8 by using
    the installed Snow Leopard online to get Combo Update v1.1 for
    Snow Leopard 10.6.8. After that is installed & updated, run the
    system's Software Update again, to see what else is available to
    that system.
    Later systems can then be looked into at Mac App Store, once
    the computer is running Snow Leopard 10.6.8.
    And if your computer is a Power PC (G4/G5, etc) and has no
    Core2Duo kind of CPU -- See "About this Mac" in apple menu
    to disclose the general info about your Mac. Also you can see
    even more by clicking on "More Info" when looking in there...
    If it isn't an Intel-based Mac, it can't run a system past 10.5.8.
    Hopefully this helps.
    Good luck & happy computing!

  • Temporary wim-files for multicast transmissions still needed for WDS installation in Server 2012 R2?

    Acording to
    https://technet.microsoft.com/en-us/library/dn281955.aspx one of the new features for WDS in Server 2012 R2 for multicast is:
    Improved multicast deployment by eliminating the need for making a local copy of the install.wim file. You can apply the install.wim file while it is being downloaded without significant impact to the application process.
    However, this doesn't seem to be activated by default and I still get the following error when installing one or more machines using multicast:
    "Windows Setup cannot locate a valid hard drive to store temporary installation files." However, once I remove Multicast from this install image, it installs without any problems at all.
    I have also noticed that while multicasting, the installation will use the "Copying Windows files" phase, while downloading and copying the install.wim (or whatever name it is) locally on the hard drive first, so this will require lots of space.
    So the question is, how do you enable this new feature that should be a part of WDS in Server 2012 R2???

    Full version:
    Following steps could help enable the feature:
    1.       Mount the boot image using dism.
    e.g.
    >dism /mount-wim /wimfile:c:\remoteinstall\boot\x64\images\boot.wim /index:2 /mountdir:c:\mount
    2.       Create a metadata file if no existing one. The metadata file should be in mountdir from the first step under mountdir\sources. And the file name should be: WdsClientMetadata.txt
    3.       Add entry to the metadata file: WDS.Client.Multicast.WIM.Streaming.Enabled=true
    4.       Save changes and unmount the boot image
    e.g.
    >dism /unmounts-wim /mountdir:c:\mount /commit
    Sorry for the late reply, but I had to test this thoroughly since I didn't get it working right away. I tried both the regedit you first mentioned, and later also creating a textfile in the "/index:2 boot.wim", both without any success. I noticed
    that creating the sources\WdsClientMetadata.txt with the data "WDS.Client.Multicast.WIM.Streaming.Enabled=true" gives me an error upon booting into WDS as follows (EUFI/IPv6-boot):
    Same happens if I boot using IPv4 (an non-UEFI boot), except that there would be a plain IPv4-address instead in the error msg. Just for troubleshooting I tried writing WDS.Client.Multicast.WIM.Streaming.Enabled=false in the file instead, and WDS would throw
    me the exact same error message. Once I delete the file sources\WdsClientMetadata.txt from the WDS/Boot image, the client boots ok, both for IPv4/IPv6. Disabling the firewall on the WDS didn't help, so something in the configuration is still missing? I'm getting
    to a dead end here, and I suppose you're all out of advice on this one?
    Thank you Shaon Shan for your great effort so far.

  • Need for multiple ASM disk groups on a SAN with RAID5??

    Hello all,
    I've successfully installed clusterware, and ASM on a 5 node system. I'm trying to use asmca (11Gr2 on RHEL5)....to configure the disk groups.
    I have a SAN, which actually was previously used for a 10G ASM RAC setup...so, reusing the candidate volumes that ASM has found.
    I had noticed on the previous incarnation....that several disk groups had been created, for example:
    ASMCMD> ls
    DATADG/
    INDEXDG/
    LOGDG1/
    LOGDG2/
    LOGDG3/
    LOGDG4/
    RECOVERYDG/
    Now....this is all on a SAN....which basically has two pools of drives set up each in a RAID5 configuration. Pool 1 contains ASM volumes named ASM1 - ASM32. Each of these logical volumes is about 65 GB.
    Pool #2...has ASM33 - ASM48 volumes....each of which is about 16GB in size.
    I used ASM33 from pool#2...by itself to contain my cluster voting disk and OCR.
    My question is....with this type setup...would doing so many disk groups as listed above really do any good for performance? I was thinking with all of this on a SAN, which logical volumes on top of a couple sets of RAID5 disks...the divisions on the disk group level with external redundancy would do anything?
    I was thinking of starting with about half of the ASM1-ASM31 'disks'...to create one large DATADG disk group, which would house all of the database instances data, indexes....etc. I'd keep the remaining large candidate disks as needed for later growth.
    I was going to start with the pool of the smaller disks (except the 1 already dedicated to cluster needs) to basically serve as a decently sized RECOVERYDG...to house logs, flashback area...etc. It appears this pool is separate from pool #1...so, possibly some speed benefits there.
    But really...is there any need to separate the diskgroups, based on a SAN with two pools of RAID5 logical volumes?
    If so, can someone give me some ideas why...links on this info...etc.
    Thank you in advance,
    cayenne

    The best practice is to use 2 disk groups, one for data and the other for the flash/fast recovery area. There really is no need to have a disk group for each type of file, in fact the more disks in a disk group (to a point I've seen) the better for performance and space management. However, there are times when multiple disk groups are appropriate (not saying this is one of them only FYI), such as backup/recovery and life cycle management. Typically you will still get benefit from double stripping, i.e. having a SAN with RAID groups presenting multiple LUNs to ASM, and then having ASM use those LUNs in disk groups. I saw this in my own testing. Start off with a minimum of 4 LUNs per disk group, and add in pairs as this will provide optimal performance (at least it did in my testing). You should also have a set of standard LUN sizes to present to ASM so things are consistent across your enterprise, the sizing is typically done based on your database size. For example:
    300GB LUN: database > 10TB
    150GB LUN: database 1TB to 10 TB
    50GB LUN: database < 1TB
    As databases grow beyond the threshold the larger LUNs are swapped in and the previous ones are swapped out. With thin provisioning it is a little different since you only need to resize the ASM LUNs. I'd also recommend having at least 2 of each standard sized LUNs ready to go in case you need space in an emergency. Even with capacity management you never know when something just consumes space too quickly.
    ASM is all about space savings, performance, and management :-).
    Hope this helps.

Maybe you are looking for

  • Transport Layer

    Hi guyz, I have a question. why do we need a transport layer between the Development system and the consolidation system?? It is really appreciated if someone can throw some light on "Transport Layer". Thanx in advance. Ashok

  • Auto closing of reversal journals

    Considering SAP is OIM (open item management) it would save considerable time if the reversing journals auto cleared upon execution.  Especially in the balance sheet accounts.  This should also include Exchange and Conversion journals. We are using S

  • Unable to view saved passwords in Safari - the box keeps un-checking itself. Advice? Help?

    Trying to view a saved passwords in Safari for particular website(s) I need to login to... so as usual I click the box to within the preference-saved UID/passwords list and by doing so allows me to view the password. However, suddenly today this litt

  • Planned order not selecting BOM and Routing.

    Dear All, I am runing LTP, but for all simulative Planned order system is not selecting Routing and BOM.When i change it manually its selecting the correct BOM and Routing. Please let me know what needed .... Regards Sathish

  • Can't open/add files to any program.

    Everytime I try to open a file in iTunes,VLC player and etc the window (that contains the files.So I guess finder(?) ) disappears.The first time within a milisecond and the second time it stays open longer.