In front of the feature for Group By... ?

Hello

I have a table of the source as follows:
PRODUCT
THE NEST | QTY.
P1 |             5
P2 |             1
P3 |            3

I want results as follows:_

THE NEST | QTY.
P1              | 1
P1              | 1
P1              | 1
P1              | 1
P1              | 1
P2              | 1
P3              | 1
P3              | 1
P3              | 1

You can see in the output table that P1 should be repeated 5 times, 1 P2 and P3 3 times because of their respective values in the QTY of the source table column.

I tried to use the WITH RECURSIVE clause, but it does not work for me (get a syntax error).

Can someone please help me to solve the problem and get the desired result?

Published by: 976056 on December 10, 2012 10:53

Hello

Welcome to the forum!

Here's one way:

WITH     cntr     AS
(
     SELECT  LEVEL     AS n
     FROM     (
               SELECT  MAX (cnt)     AS max_cnt
               FROM     product
          )
     CONNECT BY     LEVEL     <= max_cnt
)
SELECT       p.id
,       1     AS cnt
FROM       product  p
JOIN       cntr        c  ON  c.n  <= p.cnt
ORDER BY  p.id
;

976056 wrote:... I tried to use the WITH RECURSIVE clause, but it does not work for me

It is difficult to say what you're doing wrong when we don't know what you're doing. Please your postal code.

(Get a syntax error).

Error messages often give valuable information on what is the problem. Always show the error message. Even if you don't understand it, maybe someone who wants to help you understand and explain it to you.

Here's a solution using a WITH recursive clause:

WITH     r (id, cnt)     AS
(
     SELECT  id
     ,     cnt
     FROM     product
    UNION ALL
         SELECT  id
     ,     cnt - 1
     FROM     r
     WHERE     cnt     > 1
)
SELECT     id
,     1     AS cnt
FROM     r
;

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}

Published by: Frank Kulash on December 10, 2012 14:01
Added recursive SOLUTION.

Tags: Database

Similar Questions

  • How to get the configuration of the feature for UIMap value?

    Hi all
    Right now, I do a function that needs to get the value of configuration of the feature for the UIMap, anyone have the solution for this or is it just imppssible?

    You can get the values of business Invoking 'Base' = "C1-GetFeatureConfiguration" and then call the user interface mapping, where the BS is included.

  • Eclipse has all the features for the ADF?

    Hello

    Our team is using 11.1.1.7, and the question has been raised whether it is possible to use eclipse (the version of oracle).  I have read this document, but it can appply for a newer version of Jdeveloper.

    JDeveloper + ADF vs Eclipse + ADF?

    The big question is whether they can use Jdeveloper to work which is to the 11.1.17 version.  The functionalities (assistants, etc.) is available in this version of the EPCO, which would correspond to the 11.1.1.7 version?  Otherwise, available in 11.1.1.7, which version includes ALL the features appear?

    If all the features are there, what version of EPCO we need to use it so that it works perfectly with our version of jdeveloper 11.1.1.7?

    Thank you in advance!

    Best,

    Stuart

    EPCO not tooling ADF in British Colombia, control of data REMAINS (it controls of WSDL and POJO data support).

    And they do not have tooling around security ADF and MDS - even if you could possibly set up without tools by manually changing the files.

    ADF Faces page edition also does not offer a Visual Editor but rather codes, properties, the approach of the structure editor.

  • Remove the feature for the selected lines in the scrolling area

    Hello

    I created a scroll box with selector box at level 1, so that end users can select desirable to delete lines. I need help of your gurus on the removal of the line feature.

    PeopleSoft offers a built-in function to remove lines or Javascript is the best option?

    Please help me

    Thank you

    I assumed that the box was a field of a derived record that you placed on the grid yourself.
    Probably, you use the grid selection option.

    In this case you must use the property Selected of the Row object as an indicator.

    Local Rowset &RS1;
    
    &RS1 = GetLevel0()(1).GetRowset(Scroll.MBT_DEPT_TBL);
    For &I = &RS1.ActiveRowCount To 1 Step - 1
       If &RS1(&I).Selected Then
          &RS1.DeleteRow(&I);
       End-If;
    End-For;
    

    In the previous code, I had a typo in online

    &RS2.DeleteRow(&I);
    

    It must be

    &RS1.DeleteRow(&I);
    

    Kind regards

    Halin

  • Select the feature for tables

    Hello, I am looking for a function similar to a function of SELECTION, but for arrays.

    I'm doing the following:

    Say, 3 functions of random numbers are compared to a value (0.5). If the condition (is greater than) is TRUE, I need to switch a button and keep a logic for the rest of the time - so that I don't like about the value of random after number. It is important for me that the condition was true once. Therefore, it is as a function of cumulative 3 led buttons, who says at the end that the condition has been met at least once to each of the 3 comparisons (if all buttons are met).

    I managed to do it for a unique random number only, using the function SELECT and SHIFT register, but I failed to do with arrays of numbers.

    Maybe it's easy for someone of you a you can help me, because I'm stuck ...

    If this problem has been resolved already, I'm pretty sorry - but I could not find the key word to describe my problem.

    I thank you and have a nice day.

    Lefebvre

    Here is a simple code as described.

    The VI stops once all Boolean values have been true at least once. I updated the status > 0.98 to spin a bit longer. Modify if needed.

    (Note that even in your original code, a Boolean GOLD is much simpler than the function "select".

  • Change the opacity for group of objects on a single object, but not each other?

    I have a several simple objects of color filling all United over a context with a Uni fill object.  I want to reduce the opacity of objects on the object in the background.  However, my makeup of efforts the opacity of objects change on all other objects and I want to keep their strong colors.

    bg_inner.gif

    And it's the one with an opacity, but I want to stay solid on the other.

    bg_innerWrong.gif

    Thank you

    Martin

    I've selected all the objects at the top of the page and click on the little circle thing circle in the layers palette and then adjust the opacity and it seems to work very well.

    It's because you have now applied the transparency of a layer setting. (When you clicked on the Meatball, you targeted layer, no not objects).

    You could have done the same thing by bringing TOGETHER actually what you call 'a group of objects' and by applying the transparency to the group setting, instead of to individual objects. (See why it is important to try to talk in terms of the program?)

    Always have the appearance Palette open so that you can always keep your eye on what Illustrator called the current selection. It will help you avoid a lot of confusion if you keep in mind, what kind of object (Path, group, layer) said Illustrator is selected.

    JET

  • Change the display time for grouped objects

    Hello, I have problems to change the display time for the grouped items. I use 7 Captivate and I love how now grouped items display only as an element in the timeline because it reduces the number of lines visiblein the chronology for each object on a slide. However, now that the grouped objects is more individually appear in the timeline panel, I can't see all the adjustments for group objects together.

    If someone else has had this problem and is there a work around? My main problem is that if I need to extend or shorten the audio to the slide, and I assigned a tip action to be grouped in order to adjust the grouped object to match the audio, I must now separate adjust, regroup, then reset the advanced action by using the name of the new group. It's frustrating and tedious.

    To enlarge and view the items grouped on the timeline, you need to click the arrow next to the group name. Once you develop, you can select the individual object and adjust the timings.

    Alternatively, you can select the individual object in the Group on the slide and adjust the timing of the accordion of timing. You can do it without separate.

    Anthony

  • Outline/background Style for group Plugin objects?

    So I'm working on a plugin that is based on the creation of a PluginGroup and I started with the example of the live shadows.  So far everything is fine, but if you want to change the outline/fill style of the object that has the live shadow you must undo the plugin group, adjust the style on the original path and re-apply the Drop Shadow Live.   Is there a way to avoid this step?   Can I tell illustrator this plugin group object knows the style of outline and provide a way to get/set the style of the original object contour/filling directly?

    Now it is simply the flow of very heavy workload, but in the future as my plugin group object becomes more complex and has its own data, it will be unreasonable to destroy/rebuild just to be able to adjust the width of the line.

    -Kurt

    OK, sorry. For more visit, it is true that I can adjust the news of the race for the path that my group of plugin included.  I guess the problem I have is that I can adjust the width of the line by using the options menu in the tab of the race, but the options by default (top of the screen) available for this path is no longer include the options of fill/outline.

    This makes sense; the control in the upper panel displays items based on selected art. Technically, plugin art has no border or background, because they could be literally anything.

    So I start with a path, and top included options fill, stroke, opacity, basic dimensions.   When I (as shadow) put this way under my group plugin options above reduce just the opacity and basic analytical information.   The text selection is it's a Plugin object (if I select the full path) or a path so I select that some parts of the track, but I never get the fill/outline options.

    Because I can actually adjust the options of race without undo/redo the group object (more on the tab of the stroke) and my plugin reacts correctly, I suppose that this issue went to "major problem making my unusable pluin" the "minor problem that may confuse the first time users and is mildly annoying."

    So I guess my question brought down to: is it possible that my plugin object can still get the contour/background options in the options at the top bar?  (Sorry my illustrator terminology isn't at the height...) If this is probably not the right term for this space.)

    The terminology is 'control panel' I think

    In what concerns obtaining STROKE & fill to appear up there? Its technically possible, but you should be able to talk to the Panel of control through the SDK - currently there is no header, unfortunately, to do so. I think you're out of luck, at least for the moment, unless someone from Adobe can help you. Without that there is no way to inform the control panel it must show, at least as far as I know.

    Just now, I have no idea how to debug a plugin.  I've resorted to a communication around a FILE * and fprintf'ing which, and then by looking at the file after a race.  Which is a rather painful to debug way. : b

    Debugging is not too difficult. Just make sure you point your debugger to Illustrator.exe. If you create debug versions, after that he must respect the breakpoints that you set.

    I managed to get the plugin to the top and the functioning of this morning.  (With a few bugs still in there).    Because the debugging/development cycle for the plugin was so painfully, in fact, I developed all the features for the plugin in python using pygame and some data structures that mimic the illustrator structs.  I then super fast iterative development in python and then only had to translate all this in C++ and debug some errors, I have introduced in the translation process.   Kind of crazy, but my machine that has Illustrator on it is quite slow and the illustrator of compilation-raise poke if the bowels of goat fprintf in my output file of debug cycle is super painful.  Not a good way to visually debug a ton of math difficult, etc.  The trick of python has really made a lot of fun.

    I have not worked with Python in a few years, but I really enjoyed working with her!

  • Why Photoshop swatch group offers the same feature for Illustrator?

    The Illustrator swatch Panel is much more advanced and easier to use than PS version, i.e. create swatch folders, move, and delete colors from anywhere in the order, etc..

    I'm more surprised that Adobe have not improved with new versions (I'm now using the CC software and still nothing).

    Are there plans to match the features of Illustrator?

    http://feedback.Photoshop.com/photoshop_family/

    is supposed to be the right place for bug reports and feature requests.

    Some connected to Photoshop Adobe employees have been declining in this Forum and providing valuable assistance and advice, but they do so not in an official function; the official chain would be the aforementioned site.

  • Muse "Content" feature without the publication for mobile android chrome

    My company site Muse painfully simple - www.efsmart.com--est published on my server for desktop and phone.

    I've experimented with content based on marking [window > content] to synchronize the simple content between and telephone Office.

    It loads fine on the desktop, but I get the message on my browser chrome android [left image]:

    Two screen captures.png


    After clicking on OK, loading the page in basic HTML left [see the text in the above image behind the error window]. I deleted the cache of the browser mobile, re-uploaded and received the same error message. I deleted the content feature of marking on the mobile page [not on the Office page]re-uploaded, and it loads correctly in my mobile browser [right picture]. It always seems OK on my desk [Mac OS, Chrome].


    Any idea what's going on? Is a useful feature if it worked correctly.

    Unrelated with the mistake of warning we discussed, your desktop homepage is much broader than you planned due to there being an empty text frame far right of the page (almost in front of the "recent projects" section). If you find and delete this empty text in Muse design block you will not get a scroll bar horizontal in the browser when the browser window is 960px or wider.

    Your site is loading correctly for me on the phone and the desktop computer.

    It seems that your host has configured the site to treat 404 requests (URLS for files that do not exist) to redirect the request to your home page. I think this redirect is what is in conflict with the loading himself drumming homepage and find its associated files (index.css, etc.). Your site seems to work fine when a URL is entered, but if something as efsmart.com/foo/bar entered the site visitor is presented with a version not formatted to your homepage and the warning message. It's a problem with how the Organization treats 404 (file not found) errors.

    If you share this information with Pair.com they can immediately understand and be able to help to change the configuration of your site to avoid the problem. If they do not immediately understand, you can have them send me an e-mail at [email protected] with a link to this forum for the background thread and let's talk technobabble directly rather than put you in the middle. ;^)

  • adjust the ignition for a group

    Greetings.

    It is possible to adjust the ignition for a whole group in captivate 8?

    When I select a group of properties of entire calendar menu disappears.

    each element of the group can always be selected and timed individually, but that seems counter to the objectives of the Group feature.

    any advice?

    Thank you.

    No, because a group can have objects with different maturities.  Maybe sometimes it might be useful, but I personally use groups for:

    • manage objects
    • Use groups in advanced actions, much easier in many cases as hide a group, then display an item out of group
    • use groups in joint actions: because a parameter can be an object or a group, that is a lot more versatile shared equity

    Just these examples, as a response to "..." seems counter to the objectives of the group function, where I do not agree."

  • How can I get the best made for group presentations

    To 60i AVCHD Canon HFG 20 firing rate. Protruding on laptop to large groups and the need for the best video quality. I made all the ways that I can with bad quality. WMV seems to give best results, but nothing compared to the .mts files coming from the camera.

    Have you tried to share + publish a file AVCHD with H.264 CODEC?

    Do not know exactly which media players will play those to your projector, but the free VLC and MediaPlayer Classic HC player must also manage these files.

    Also, what are the features of the projector - any restrictions on the size of the image?

    Good luck

    Hunt

  • Ungroup a group and keep the scriptlabel for each item in the Group

    Hello

    does anyone know how to ungroup a group of rectangles with a certain tag (example groupA) give one every rectangle a clean label (the same text groupA)

    I can find the Group and ungroup it but I can't label the rectangles...

    var oPageItems = app.activeDocument.allPageItems;

    for (var j = oPageItems.length - 1;)  j > = 0; d-) {if (oPageItems [j] .label == ("groupA")) {oPageItems [j] .ungroup ()))}}

    ...???

    Help, please

    Hello

    front

    oPageItems [j] .ungroup ();

    go through the loop and set a label for each item within the Group:

    for (var k; k)< opageitems[j].length;="">

    oPageItems [j] [k] .label = "groupA";

    assuming that your oPageItems [j] is a group indeed.

    I hope that...

  • I do my job to the computer on a MAC computer. I want to create a document using Pages and then convert the document to PDF and send a group email. I want to send the PDF using the pdf for each receiver icon must click the icon to open t

    I do my job to the computer on a MAC book PRO. I want to create a document using Pages and then convert the document to PDF and send a group email. I want to send the PDF using the pdf for each receiver icon must click the icon to open the document. My problem is the document does not show the icon, but rather the document is already open. I spoke with 2 Apple. 'Experts' care and can help me. Can someone tell me what to do?

    It's a question of how the recipients e-mail programs deal with attachments. Many e-mail programs will open all the files they can handle, including files jpg and PDF, by default, and if the recipient has not changed that there is nothing you can do about it. The only solution is to the compress first, then it will be delivered as an attachment, allowing the recipient to decompress and open it.

  • Search for open tabs of AwesomeBar using % in front of the term does not work in 35 FF. Is this a problem, or am I missing something?

    This procedure to search open tabs of reference for many pages, but only a new tab opens. I tried both cela url (address) bar and the bar of search without success without success. The AwesomeBar should be activated or is there something I am doing wrong?

    I found references to the operator percentage here:

    http://blog.Mozilla.org/theden/2012/04/30/Firefox-tips-search-your-open-tabs/

    https://plus.Google.com/+Firefox/posts/GFdB534oWEK (these two say that the operator will in front of the term)

    (But this clarified things for me)
    and in the page you quoted, lowest in "change the results on the fly

    If you are looking for a particular type of outcome, such as a bookmark or tag, you can speed up the process to find by typing in special characters [after] each search term in the address bar separated by spaces:...

    The results are quite specific.

    My problem was that I had no connection at all with AutoComplete and wasn't looking for results but instead pressing on enter. No wonder. These are some gems for my purposes. Thanks for your help Curtis.

Maybe you are looking for