[8i] Way to add a specific nbr of rows based on a column value? (Follow-up)

I'm dealing with an old database that's being phased out, and here's the version info (yes, it's really old):
Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production
PL/SQL Release 8.1.7.2.0 - Production
CORE 8.1.7.0.0 Production
TNS for HPUX: Version 8.1.7.2.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
I believe Frank Kulash gave me the solution to my original question, which was:
Sample data:
CREATE TABLE     testabc
(     item     CHAR(25)
,     qty     NUMBER(13,4)
INSERT INTO     testabc
VALUES ('Item1',1);
INSERT INTO     testabc
VALUES ('Item2',3);
INSERT INTO     testabc
VALUES ('Item3',1);
INSERT INTO     testabc
VALUES ('Item4',2); Desired results:
ITEM                                  QTY
Item1                               1.000
Item2                               3.000
--blank row
--blank row
Item3                               1.000
Item4                               2.000
--blank rowAnd the solution:
SELECT       CASE
          WHEN c.n = 1  THEN  t.item
       END          AS item_col
,       CASE
           WHEN c.n = 1  THEN  t.qty
       END          AS qty
FROM       testabc  t
          SELECT     ROWNUM     AS n
          FROM     all_objects
          WHERE     ROWNUM     <= 10     -- If you know an upper bound
       )          c
WHERE       c.n     <= t.qty
ORDER BY  t.item
,            c.n
;Now, it turns out there are only some items which need these extra rows, but I'm not sure if it's possible to only include extra rows for certain items or not...
Here's my new sample data:
CREATE TABLE     testabc1
(     s     CHAR(1)
,     item     CHAR(25)
,     qty     NUMBER(13,4)
INSERT INTO     testabc1
VALUES ('*','Item1',1);
INSERT INTO     testabc1
VALUES ('','Item2',3);
INSERT INTO     testabc1
VALUES ('*','Item3',3);
INSERT INTO     testabc1
VALUES ('*','Item4',2);And my new desired results: (any row with an asterisk gets extra rows, if the qty is greater than 1)
S ITEM                                  QTY
* Item1                               1.000
  Item2                               3.000
* Item3                               3.000
--blank row
--blank row
* Item4                               2.000
--blank rowEdited by: user11033437 on Jan 3, 2012 9:27 AM (fixed missing asterisk in desired results)

Hi,
Here's a slightly simpler way:
SELECT       CASE
          WHEN c.n = 1  THEN  t.item
       END          AS item_col
,       CASE
           WHEN c.n = 1  THEN  t.qty
       END          AS qty
FROM       testabc1  t
          SELECT     ROWNUM     AS n
          FROM     all_objects
          WHERE     ROWNUM     <= 10     -- If you know an upper bound
       )          c
WHERE       c.n     <= CASE
                   WHEN  t.s  = '*'
                   THEN  t.qty
                 ELSE  1
             END
ORDER BY  t.item
,            c.n
;This is just like the previous solution, except that the WHERE clause, which was originally
WHERE       c.n     <= t.qtyis now
WHERE       c.n     <= CASE ... END
user11033437 wrote:... And my new desired results: (any row with an asterisk gets extra rows, if the qty is greater than 1)
S ITEM                                  QTY
* Item1                               1.000
Item2                               3.000
Item3                               3.000
--blank row
--blank row
* Item4                               2.000
--blank row
S should be '*' on the output row where item='Item3', right?
I'm sure you know how to get the s column in the output, but, since I've already tried it:
SELECT       CASE
          WHEN c.n = 1  THEN  '*'
       END                AS s
,       CASE
          WHEN c.n = 1  THEN  t.item
       END          AS item_col
,       CASE
           WHEN c.n = 1  THEN  t.qty
       END          AS qty
FROM       testabc1  t
          SELECT     ROWNUM     AS n
          FROM     all_objects
          WHERE     ROWNUM     <= 10     -- If you know an upper bound
       )          c
WHERE       c.n     <= CASE
                   WHEN  t.s  = '*'
                   THEN  t.qty
                 ELSE  1
             END
ORDER BY  t.item
,            c.n
;Edited by: Frank Kulash on Jan 3, 2012 11:11 AM

Similar Messages

  • How to dynamic to add +/- 10 to the y axis based on returned data value max/min

    Hi,
    We have two ways to extract/present the data/chart. One is using SQL Reporting and one is using EXCEL. However, we hardcoded the max/min value on y asix to various data set so the chart looks good. However, SQL reporting seems using auto on the y asix so
    when some values are 0, it just overlapped with the x-asix as dipicture below (left hand side is SQL reporting and right hand size is EXCEL) 
    Please advise how to add an +/- interval on the y asix based on the max/min returned data value (e.g if the max returned value is 100 and min returned value is 0, the max value on y asix would be 110 and min value of y asix would be -10)
    Thanks

    Hi kkcci88888,
    According to your description, there is a chart in the report, you want to set vertical axis range and interval dynamically. For example, if the max value of the column is 100 and min value is 0, the max value on y axis would be 110 and min value of y axis
    would be -10. If that is the case, please refer to the following steps:
      1. In design surface, right-click Y axis and open Vertical Axis Properties dialog box.
      2. In Axis Options pane, click (fx) button next to Minimum and type the expression like below:
    =Min(Fields!num.Value)- 10
      3. Click (fx) button next to Maximum and type the expression like below:
    =Max(Fields!num.Value)+ 10
      4. Set Interval to 10, Interval type to Number.
    The following screenshots are for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu

  • Add different UI in each row based on conditions in ALV

    Hell All,
    i am working on dynamic ALV in which i have created 3 methods 1. which creates the columns 2. Which sets the data into teh created columns. 3. which does teh alv customizations.
    So now my requirement is based on some condition i want to change the UI element 
    eg
    i have
                                  column1      column2            column3
                                      1            link_to_action     name
                                      2            link_to_url          name2
    so based on the condition i would like to display the ui elements as above.
    I was able to do till this end so far..
    1.in create_columns method i created a column call cell_varaint
    2 when i was passing data into the columns
    'when column1'
      IF  colum1 = 1.
    <field> = 'link_to_url'
    else.
    <f_field>  = ' '.
    endif.
    when 'column2'
          CREATE OBJECT lr_link_to_actn.
                 <ls_column>-r_column->set_cell_editor( lr_link_to_actn ).
                 CREATE OBJECT l_cv.
                 l_cv->set_key( value = 'LINK_TO_URL').
                 l_cv->set_editor( value = lr_lnk_to_url ).
                 <ls_column>-r_column->add_cell_variant( r_cell_variant = l_cv ).
                 <ls_column>-r_column->set_sel_cell_variant_fieldname( 'cell_varaint).
    so now i am able to get only empty column with no data into it ... and my cell varaint column shows me the values like LINK_to_URL or space.
    I am sure tht some where i am missing something...
    Please tell me the correct procedure to use it...
    Regards,
    Sana.

    I hope it is Hello not Hell
    if i understand your question correctly, You want the first row of column to LinkToAction UI element and second row LinktoURL.
    follow the link where it is nicely explained however he is making one row as text view and other as checkbox.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d136d?quicklink=index&overridelayout=true

  • I keep on forgetting ALT B (I think that's it). Is there any way to add options to the bookmark pulldown, specifically "Bookmark all Tabs" ?

    I keep on forgetting <ALT> B (I think that's it)?
    Is there any way to add the "Keep All Tabs" to the pulldown Bookmark menu?

    You can make all hidden menu entries visible with this code in userChrome.css below the @namespace line.
    * http://kb.mozillazine.org/userChrome.css
    * http://kb.mozillazine.org/Editing_configuration
    You can use the ChromEdit Plus or Stylish extension to have easier access to the customization files.
    * ChromEdit Plus: http://webdesigns.ms11.net/chromeditp.html
    <pre><nowiki>@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    #navigator-toolbox menuitem[class="show-only-for-keyboard"]{ display:-moz-box!important; }
    </nowiki></pre>

  • How to add a specific view to a folder in Finder?

    Hello Everyone,
    I was wondering if there is a possibillity to add a specific view to a specific folder in Finder.
    I know this sounds abstract, let me explain:
    In OS 10.5 there are now 4 views for the Finder:
    - Icons
    - List
    - Columns
    - Cover Flow
    Usually I prefer icons, but for my movies and pictures folders I prefer Cover Flow.
    It would be handy to preset Cover Flow as view for the movies and pictures folders while other folders remain unaffected and still view as icons, instead of constantly having to change the view.
    Is there any way to accomplish what I am trying to do?
    Thanks Beforehands

    Lawrence,
    What you want to do is possible.
    Open your folder (the one you want to "customize"), then choose View>Show View Options. At the top, you will see a check-box labeled "Always open in xxx view," "xxx' being whatever view is currently set for the open window. Change the view on the window, using the icon in the Toolbar, to set your desired view, then enable the checkbox in the View Options. Close the View Options, then close the window.
    Initially, changing the view on this one window will change your view globally. Not a problem; just change the global setting back to your desired view when you open the next Finder window.
    Scott

  • Is there a way to add/delete words from the predictive text ?

    Is there a way to add/delete words from the predictive text options that my iPhone is giving me? I'm using an iPhone 6 Plus with iOS 8.
    There are specific words that are popping up in the area right above the keyboard where it displays 3 word suggestions to choose from. This area seems to suggest words that I have typed before, I'd like to remove these words. Default seems to select the word in the center and when I'm typing fast on occasion it will recommend and select words that I don't need to use.
    Any help would be appreciated.

    999753 wrote:
    I know in 10g delete is added but in 9i i can only work with UPSERT( update, insert)
    is there a way to add delete into 9i MERGE? or somehow encapsulate it?
    Thank youI would suggest upgrading to a supported version of the database. 9i has been unsupported for many many years now.
    And to answer your question... to the best of my knowledge, there is no workaround. It works as it works.

  • How to add a specific order type into any particular report

    Hi All,
    How to add a specific document type(order type) into any particular report in order to review OTD performance.
    I need to add one specific order type to existing reports which will help to check the performance of the delivery type for that particular order type to the users.
    Thanks,
    Raj

    Hi Rajesh,
    thanks for the reply when i tried as the way you said.. but the system is asking more details like varient. so if you can clearly specify the process for order type (VOV8-- table TVAK) so it will helpful for me.
    Thanks
    Raj

  • Is there any way to add sub-mailboxes to the Inbox in Mac Mail 4.5?

    So, back when I was using Mail 3.0, I was able to create new mailboxes/folders within the INBOX of a specific account.  When I upgraded my machine, Mail changed to "Locations" with the generic locations "MAILBOXES", and "ON MY MAC", "REMINDERS" as well as locations for any account, say "IMAP" and "EXCHANGE".  Currently, I can add a new mailbox, but my only options are to add to "ON MY MAC" (and any subfolders within), "IMAP", and "EXCHANGE".  The option of adding mailboxes to anything under the "MAILBOX" tab is not an option.
    What I'm wondering is if there is a way to add mailboxes to accounts and have it show up under the MAILBOXES location, rather than under the specific mail account location, as each mail account, ("IMAP", "EXCHANGE") also holds additional folders for Trash, Sent, Drafts, etc.  I have about two to three folders per account that I would like to keep stored on the server, and when Mail is handling multiple accounts, using the "locations" for each account takes up a surprising amount of space.
    I know that there is a way to get sub-mailboxes for each account in the MAILBOXES location (as I currently have several in an IMAP account), but these were all carried over from Mail 3.0 and any additional mailboxes are delegated to the location "IMAP" rather than MAILBOXES/IMAP/sub-mailbox.
    Basically, I'm wondering if I can create mailboxes like this: MAILBOXES/Account/Mailbox rather than ACCOUNT/mailbox
    *I realize I asked the question several times, but hopefully the additional wording helps to solve the issue.

    There is no way to add anything to the face of a photo in iPhoto at all You will need an extenral editror for that kind of work. You can add text and arrows etc with Preview, already on your Mac or with apps like these:
    Seashore (free)
    The Gimp (free)
    Graphic Coverter ($45 approx)
    Acorn ($50 approx)
    Pixelmator ($50 approx)
    Photoshop Elements ($75 approx)
    There are many, many other options. Search on MacUpdate or the App Store.
    You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.

  • What is the best way to add a large number dynamic VI's in the application builder?

    Is there a way to add all the VI's in a directory tree or library file as "Dynamic VI's" in the application builder (7.1 on Windows XP SP2)?
    Thanks,
    Mark Moss

    LabVIEW 7.1: From what I can tell, you can only add dynamic VIs one file at a time, while for support files, you can add entire folder contents.
    Have you considered uprading to LabVIEW 8.0? Things like this have been improved dramatically! You can keep all your dynamic VIs in a project folder, then add it to the build specification in one click.
    LabVIEW Champion . Do more with less code and in less time .

  • Is there a way to add other transactions to Applications in BDT menu?

    Hi Masters!
    I'm trying to learn how BDT works. I'm trying to use it to make my own checks in some standard fields. So far I'm able to call my own function at 'View'->Further Checks. It's working fine.
    But my problem is:
    At the BDT menu (BUPT) there is only one Application (Maintain Business Partner - transaction BP). But I want to check the fields (Tax Numbers) in another transaction (BBPMAININT).
    Does this mean that I can only use the BDT controls in this transaction? (It seems to be so; I couldn’t get into my function with BBPMAININT)
    Is there a way to add other transactions to the 'Application' folder, so I can manipulate the fields, views or screens? If there is please tell me how... I checked the documentation but couldn’t figure out...
    Do you have any other ideas of how to make my validations with the standard field (withou changing the standad code)? (NOTE: there is no BADI to do this).
    Thanks in advance,
    José Omar

    Write a custom carousel.  Usually carousel components are just ULs that use something like jQuery to rotate through the LIs.  The foundation carousel component is really just designed for some specific use cases.  Generally I would just recommend rolling your own.

  • Is there a way to add images , text and button in the individual marquee of a carousel

    Is there a way to add images , text and button in the individual marquee of a carousel ?

    Write a custom carousel.  Usually carousel components are just ULs that use something like jQuery to rotate through the LIs.  The foundation carousel component is really just designed for some specific use cases.  Generally I would just recommend rolling your own.

  • Best way to add a new section in the middle of a tune?

    hi,
    what's best way to add a new section in the middle of a tune? I think I came up with an interesting transition to a tune... what's the best way to try it out?
    please be specific. if it's just select all and cut and move - I already know that one. somehow, I bet there's a better way.
    thanks in advance...

    You should be able to enter the "in" and out" points in the transport bar. And then under the Region menu, choose "Cut/Insert time."
    So if, for instance, you go up to bar 32, and want to add 8 bars, enter 32 1 1 1 in the top transport place, and 40 1 1 1 in the second. Then select "Cut/Insert Time", and an 8 bar whole will be added to your song.
    Be aware that if there are overlapping MIDI notes found at that cut point, Logic will warn you about it, and give you some options. In this case, I think "Keep" would be what you'd want, but every situation is different...
    Hope that helps....

  • Ways to add photos to a collection?

    When editing images (meaning, performing selects/rejects) I like to use collections. Is there (or can there be) a better way to add images to a specific collection other than dragging & dropping? It might be beneficial to have a contextual menu to send selected photos to an existing collection. As it stands, there's an option to add to a Quick Collection or to find what collections a particular image currently resides in. I don't like using Quick Collections, especially if I have several collections that one image might go into, so it would just double my work to go from Quick Collection and then into the collections I really wanted in the first place.
    Is what I'm looking for possible? If not, is that something anyone else here would find useful? What's the method of requesting features from Adobe?

    You can press "B" to add to a quick collection for temporary use and then move the entire quick collection to a permanent collection later if you needed to.
    edit sorry i missed the OP.  Disregard

  • Stickie Notes - a way to add a top label?

    In stickie notes, is there a way to add a header label to a note (in the top darker yellow area?
    Also, is there a way to create different groups of notes. Example: a group called GROCERY LIST, then maybe a group called MAC HELP ME NOTES, and maybe a group FRIENDS EMAIL ADDRESSES ???
    Then in stickies you could open the group you need to view notes in, like the GROCERY LIST NOTES and save the group separate from the other groups. Kind of like having a do it yourself rolodex card database. One group for this subject, and another group for another subject. Maintain several "groups" of specific notes or subjects.
    If this is not possible, it should be an added feature for stickie notes app.

    No. The parental settings only apply to purchasing and not playback and the parental advisory labels cannot be added on specific content.

  • What is the proper way to add 16GB ram to the existing 8GB in my 27" Retina iMac?

    I've searched the web for the best answer to this question: What's the best way to add 16GB ram to the existing 8GB in my late 2014 Retina iMac (ending up with a total of 24GB ram)?
    I'm seeing conflicting and ultimately confusing advice. Most people are saying to just pop in the new 16GB (2X8GB) into the 2 open slots and you're done. Others are saying no, remove the 2 4GB sticks, replace those now empty slots with the 2 new 8GB sticks, and put the 4GB sticks in the remaining 2 slots, which viewed from the bottom would be 8,4,8,4.
    A third option (to make things even more confusing) seems to be keeping the 2X4GB and 2X8GB sticks together, side by side, so that viewed from the bottom you'll see 8,8,4,4 or 4,4,8,8.
    I have no idea which configuration is best: They all seem to "work" according to those advocating their method. I want to know what Apple recommends, if they indeed have a preferred method.

    Crucial. 16GB 2X8 204P SODIMM PC3-12800 MAC to be specific.
    The OEM RAM is in slots 2 + 4 from the top, at least in mine. BANK 0/DIMM0 and BANK 1/DIMM0.
    A little background: I installed new RAM in the slots last week when my new iMac arrived, in the open slots, 1 + 3 from the top. I then started up for the first time and installed my account from Time Machine. So far, so good. About 2 hours into my first day usage I started getting random crashes. By day 2 I'd had maybe 15 crashes and a dozen kernel panics. I removed the RAM and re-seated it. Same problem. I created a new user account, thinking maybe I had some corrupt data. Ran fine for a couple of hours then BOOM same problem, again. Removed the new RAM and presto, no more crashes, going on 4 days now. I returned the RAM to the vender, requesting a replacement in the hopes that I just had a bad stick (even though I ran TechTool 7 and found no problems... which struck me as weird).
    So now I'm a little bit concerned about using the best, most Apple-approved method for installing the replacement RAM when it arrives. I'm not exactly a newbie. I've read things in the past about it being important to install RAM in a specific order, but it's been a while since I've had a new Mac, and things change. I want to be careful, but it sounds like it doesn't matter a whole lot. My fingers are crossed, not that I'm superstitious.

Maybe you are looking for

  • PL/SQL Developer

    Hi, can anyone tell when exactly does a Pl/SQL Developer becomes inevitable in a project? #Can you explain a real time situation(with respect to a project) when a pl/sql developer plays his role in a project. #Will the front end for such projects be

  • How to activate or import playlists from newly moved iTunes library on an external hard drive?

    I have just moved my whole iTunes library from my notebook to an external HDD, due to space constraints. I followed the Apple steps to do so, and finally got all my songs and the rest to appear in the player. However, my custom playlists do not appea

  • Itunes completely messed up...

    i tried searching through threads to find this but no luck, so hopefully somewhere can answer or help me here. im having a MESS load of problems with my itunes since i reformatted my computer. i reinstalled the newest version many times, updated my i

  • DUPLICATE by bRMAN in 8i

    Hi, first I have : List of Backup Pieces Key Pc# Cp# Status Completion Time Piece Name 1141 1 1 AVAILABLE 07/07/07 C:\ORACLE\ORADATA\BACKUP\DB1\DF_DB1_627298613_1_1 List of Datafiles Included File Name LV Type Ckp SCN Ckp Time 1 C:\ORACLE\ORADATA\DB1

  • PSA DOUBT

    Hi gurus In one of my intereview there asked me where we can find psa data finally  that mean which table we can see ,(i said its in RSTSODSPART)  if i'm wrong plz do correct me .. when i entered in se16 and given table name as RSTSOSDPART ,its given