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.

Similar Messages

  • How can I get a refund for the u2 album that Apple charged me for

    I have just been charged £27.99 for the U2 album that I did not want. How do I get a refund for this. I can't stand U2!!

    £27.99 for the album ? If you are referring to The Songs Of Innocence album (£7.99) then that was given free to everyone three months ago, and was free until 13th October - you are sure that you've been charged, it's not a temporary store holding charge ? The purchase price should show on your account's purchase history : See your purchase history in the iTunes Store - or http://reportaproblem.apple.com on your iPad.
    If you have been charged for the album but you didn't buy it then try contacting iTunes Support via the above 'report a problem' link.
    Or you can try contacting iTunes Support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • How can i get windows drivers for the 2013 MacBook Pro Retina?

    Hi there,
    today I have installed on my late 2013 MBP retina via the Boot Camp Windows 8.1. The installation was smoothly but some drivers are not present including the wifi driver.
    Through online research, I found out that in the current version of Boot Camp no drivers for the 2013 model are listed. Do you have one probably have an idea how to get it to run anyway?

    For feedback from experienced users,  post in the Final Cut Pro X forum here.
    They should be able to offer suggestions for training.
    Apple - Final Cut Pro X - Resources

  • How can we get record numbers for the rows after grouping them?

    Post Author: preethibaddam
    CA Forum: Formula
    hii everyone,
    i want to number those records which are grouped by a column.
    eg: if i group the emp table with the deptno then the records for the deptno10 group should start from 1 and end with an N number and again when it shifted to deptno20 group than the records for that deptno20 should again start with 1 and end with N number.
    i tried placing record number from the field explorer but it is not working. the other group records start with the ended number from the first group.
    thanks

    Post Author: V361
    CA Forum: Formula
    Record number from CR will count all the records.  You could use a running total, and reset on change of group.

  • How can I get an invoice for money taken from my card?

    How can I get an invoice for the money taken from my card???

    Hi
    You can login to https://www.adobe.com/account/account-orders.html and print your invoice.
    Thanks
    -sarabjit

  • How can I get someone to answer the phone? I'm ready to give VERIZON my business. I sat on the phone for over 20 minutes only to be transferred to "Sales." I then sat on the phone for another 15 minutes!!!! I finally hung up.

    How can I get someone to answer the phone? I'm ready to give VERIZON my business. I sat on the phone for over 20 minutes only to be transferred to "Sales." I then sat on the phone for another 15 minutes!!!! I finally hung up.

    It takes an enormous amount of patience and time to get through to a qualified person.
    My Samsung S5 was locked out and needed a factory reset. Including attempts to achieve this locally, it took over an hour before my problem was even addressed.
    You may be interested in my journey to a very good technical support person.
    First I called the local sales person who had given me his personal business card with the friendly advice to call me with any questions. No answer at about 8:30 am when the business was open. His voice mailbox was full.
    Then I called the local store where I had purchased the phone. The person who answered the phone had learned all the proper stock phrases, but was not familiar with the issue, stated that there were no customers in the store, and I should go there in about an hour when there would be more staff. He suggested dialing *411 from my phone (which was locked). Then he gave me a number to call Verizon, which he had to look up, and it took a minute or so. The number was (removed). That is an internal number for employees and contractors and requires a code to access, obviously not designed for customers' use. He finally cut me off by stating that there were a number of customers in line waiting for his attention!
    After researching all my papers I found 800-922-0204 on my bill. The automated message suggested a hold time of 5 minutes, it took 20 minutes for a Customer Service Representative to pick up, and then I was referred to technical assistance. The hold time was announced to take 5 minutes, after 12 minutes I finally was connected.
    Fortunately I had my computer set up for Skype on a loudspeaker, and was able to do some other paperwork while waiting.
    Persistence was rewarded by having the good fortune to be connected to a very experienced, qualified and patient technical support staff with the name of Thomas (removed). He solved my problem, answered my questions during the process of resetting the phone, and gave an example of courteous and kind customer service that I had never experienced before when dealing with any major internet company.
    >> Edited to comply with the Verizon Wireless Terms of Service <<
    Edited by:  Verizon Moderator

  • HT1904 How can I get a refund for apps in the apple App Store that do not work and are not what they said they wer

    How can I get a refund for apps in the apple App Store that do not work and are not what they said they wer

    You've tried deleting and redownloading them and seeing if they then work and tried contacting the developers ? If you have and they can't/won't help then try the 'report a problem' page to contact iTunes Support : http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes support via this page : http://www.apple.com/support/itunes/contact/- click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • HT201318 how can i get a refund for my icloud upgrade? i am within the 15 days

    how can i get a refund for my icloud upgrade? i am within the 15 days

    If in the US, follow the link below -
    https://discussions.apple.com/message/16968425#16968425
    it gives the USA number - if you don't live there you will have to find an equivalent number from the 'Contact Us' link at bottom right of this page.

  • How can I get a refund for a product I don't want as its not performing the way I want it?

    How can I get a refund for a Mac APp store product I purchased which I dont want?

    Apple views sales as final. Have you contacted the developer about the issue that you have with the app?
    When the emailed receipt arrives you can start a conversation with iTunes/Mac App Store Support about a refund via the Report link.

  • How can I set home page for a new tab? how can i get firefox to open the home page every time i open a new tab in Windows vista home basic??

    How can I set home page for a new tab? how can i get firefox to open the home page every time i open a new tab in Windows vista home basic??
    == This happened ==
    Every time Firefox opened

    Firefox can have multiple home pages if you wish. Each home page that will open when starting Firefox is separated by the "|" character.
    See: http://support.mozilla.com/en-US/kb/How+to+set+the+home+page
    To have new tabs open a specific web site, add one of the following extensions:
    http://sogame.awardspace.com/newtaburl/
    https://addons.mozilla.org/en-US/firefox/addon/777

  • After copying a movie to the harddisk of my MacBook I wanted to also copy it to my iPad, but for this you first have to copy it to the library in iTunes, but this doesn't seem to be working. So how can I get this movie to the library ? And to the iPad ?

    After copying a movie to the harddisk of my MacBook I wanted to also copy it to my iPad, but for this you first have to copy it to the library in iTunes, but this doesn't seem to be working. So how can I get this movie to the library ? And to the iPad ?

    How is it not working?  And how are you doing it?  Drag the movie onto the iTunes icon on the Dock...  what happens?

  • I ordered Illustrator for another user.  I received an invitation that was accepted, logged in and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person?

    I ordered Illustrator via creative cloud for another user.  I received an invitation that was accepted  and tried to change the account to the name and email of the person it was ordered for.  How can I get this changed and the invitation sent to the right person? 

    Cloud as a Gift https://forums.adobe.com/thread/1665610

  • How do I clear a song that won't download in Itunes?  Also, can I get a refund for the song?

    How do I clear a song that won't download in Itunes?  Also, can I get a refund for the song?

    Hi Allan ..
    From your iTunes library, right or control click the song then click Delete.
    Apple's policy states that, "all sales are final" >>  iTUNES STORE - TERMS AND CONDITIONS

  • I've just found the keyboard shortcut in Garageband for 'copy region' had changed from cmdC to ctrlC. I went to Preferences and clicked Restore Defaults for shortcuts. Now its altC . How can I get it back to the original commands.

    I've just found the keyboard shortcut in Garageband for 'copy region' had changed from cmdC to ctrlC. I went to Preferences and clicked Restore Defaults for shortcuts. Now its altC . How can I get it back to the original commands.

    When I use find file http://www.macupdate.com/app/mac/30073/find-file (which does tend to find files that "Finder" can't), it's not coming up with any other itunes library files that have been modified in the past week, which I know it would have been - unfortunately, I don't have a very recent backup of the hard drive.  It would be a few months old so it wouldn't have the complete library on it....any ideas?  I'm wondering if restarting the computer might help but have been afraid to do so in case it would make it harder to recover anything...I was looking at this thread https://discussions.apple.com/thread/4211589?start=0&tstart=0 in the hopes that it might have a helpful suggestion but it's definitely a different scenario.

  • HT201272 My laptop pc got stolen, how can I get hold of all the itune music I purchased, or at least get a list for insurance?

    My laptop pc got stolen, how can I get hold of all the itune music I purchased, or at least get a list for insurance?

    Yu can try this program.  If unsuccessful, the contents of the iPod will be deleted if yu update/restore with the iPod in recovery mode.
    RecBoot: Easy Way to Put iPhone into Recovery Mode | Jaxov

Maybe you are looking for