Problem of correspondence between the values in a table

I have a table of product

Qty of level type ID Grp
ABC 101 1 1 100
101 80 1 2 ABC
101 3 1 65 ABC
ABC 101 1 2 45
ABC 101 2 2 100
101 3 2 10 ABC

Here, I need to check if the level (id.grp), type = 2 present in type 1 and type 2 = quantity is greater than 40% of the quantity of type = 1

Finally, we should get

Qty of level type ID Grp
ABC 101 1 2 45 (more than 40% of 100)
ABC 101 2 2 100 (more than 40% of 80)

Please help me

Thanks in advance
SELECT *
  FROM product p1
 WHERE p1.TYPE = 2
   AND p1.qty > (SELECT MIN (p2.qty * 40 / 100)
                   FROM product p2
                  WHERE p1.id = p2.id
                    AND p1.grp = p2.grp
                    AND p1.level_ = p2.level_
                    AND p2.TYPE = 1
                )

Kind regards
Vijay

Published by: Vijaya Sekhar Reddy P on November 18, 2009 18:03
Changed MAX and MIN

Tags: Database

Similar Questions

  • Packets exported 11 g, but when I import on 12 c error of ' the target 11.2.0.3.0 database is an older version of the 12.1.0.1.0 source. Thus the storage clause is ignored to avoid problems of incompatibility between the versions. »

    Packets exported 11 g, but when I import on 12 c having error of ' The 11.2.0.3.0 target database is an older version of the 12.1.0.1.0 source. Thus the storage clause is ignored to avoid problems of incompatibility between the versions. »

    When I export only 1 package and then import, then I have no error and imported successfully, but when I do bulk above mention error comes.


    How can you make with the help of the SQL Developer or query?


    Kind regards.

    The problem is solved since
    Impdp iris/tpstps@PCMS full = Y dumpfile INCLUDE PACKAGE VERSION = 11.2.0.3.0 = packagespcmsTWO.dmp =
    query

  • Semi colon separated between the values

    Hello

    I have a table:

    CREATE TABLE TEST_A

    (

    ATT1 VARCHAR2 (10),

    ATT2 VARCHAR2 (10),

    ATT3 VARCHAR2 (10),

    ATT4 VARCHAR2 (10));


    INSERT INTO TEST_A

    VALUES (NULL, 'A', NULL, 'B');


    INSERT INTO TEST_A

    VALUES(,'D',,'E');


    COMMIT;


    I want that the output voltage: select * from test_a as:


    A; B

    D; E


    I want a semicolon separated between the values. If the first column has no value, it must not start with a separator semicolon.


    Thank you


    SELECT a.*,

    TRIM)

    BOTH

    ';'

    OF REGEXP_REPLACE)

    Att1 | ';' ||

    att2 | ';' ||

    att3 | ';' ||

    ATT4,

    ';+',

    ';'

    )

    ) att_list

    OF test_a one

    /

    ATT1 ATT2 ATT3 ATT4 ATT_LIST
    ---------- ---------- ---------- ---------- ----------
    A                     B          A; B
    D                     E          D; E
    A                                A

    SQL >

    SY.

  • Setting the value of a table of ActiveX control

    When controling a VI through ActiveX, how is possible to set the value of a table control?

    With digital controls, I have a problem: I just use SetControlValue and it works well:

    til SetControlValue ('y', 4) for example.

    However, in trying to do the same thing with a table, the control's value becomes an empty array:

    til SetControlValue ("arr', [3-4-5]") for example.

    What is the right way to do it?

    Hi Calvin,

    Have you tried passing a string and convert it to an array entry?  You can also try to use a 'matrix' control, rather than a table, as they are handled a little differently.

  • Alternative to obtaining the value of a table

    Nice day!

    I am new to the forum and Oracle (<-SQL Server Dev), I would like to know if there is an alternative to get the values in a table. I would like to avoid catching an exception if there is no data found especially and always continues with it.

    declare
    number of v_number;
    Start
    Select code in v_number from someTable where id = 1;

    -I still want to continue despite no data
    If v_number is null then
    -do something
    v_number: = 1; -1 initialization

    end if;

    -Continue normal processing.
    -other codes

    end;

    Thank you

    Welcome to the forum.

    Read about the MANAGEMENT of EXCEPTIONS like NO_DATA_FOUND.
    See: {message identifier: = 9360013}

    And of course the docs @ http://www.oracle.com/pls/db112/homepage
    http://www.Oracle.com/pls/db112/search?remark=quick_search&Word=exception+handling

  • How to load the values into a table?

    In my jspx page, I have a combo and a table... Based on the values of the drop-down list, when I click on a button, I want to load the values into a table... The data in the table are from 5 database tables. I created a viewObject readonly... What to do to load the values from the table, I click on a button?

    Ensure that you have defined a variable to bind your view object.

    Read-only or not, this is what would make the Execute with action of parameters available.

    John

  • Updated between the values

    Hello

    Could someone help me with a very trivial problem.

    I have after the update clause, but it gives the error ORA-01427. Seems that it is between the two problem. How should I change what he begins to work?

    Update sales_in

    the value of sale = (select a.sales in the sales_out one

    where a.sales_year_month between 201501 and 201505);

    Update sales_in I

    the value of sale = (select a.sales in the sales_out one

    where a.sales_year_month = i.sales_year_month

    )

    where i.sales_year_month between 201501 and 201505;

  • Spaces between the values in the output

    Hi all

    I have a doubt, this is the scenario in the report.

    Try to display the names of channel which is a special category in the bottom of the report. The names are identified by the DESCR field in the <? FIELD? > tag, starting with a. (ex: A-SONY).
    But there are some other channels to come between the two, as the commercial channels. Comes it like that.
    <? FIELD? >
    <? DESCR? > A-SONY <? / DESCR? >
    <? / FIELD? >
    <? FIELD? >
    <? DESCR? > B-SPORTS <? / DESCR? >
    <? / FIELD? >
    <? FIELD? >
    <? DESCR? > A-STAR <? / DESCR? >
    <? / FIELD? >

    Now, when we display these values, it displays properly, but leaving a space between them, because it has other values in the meantime.
    Can we avoid this space?, this creates some alignment problems.

    Thanks in advance,
    Imtiaz.

    You can do it like below, so that it picks up the values beginning with 'A' alone

  • Going crazy on the values of stale table f *.

    Some seriouse need help now.

    My goal is to build a table whenever a real touch.

    1. create a table based on the values programitlitly beeing past in the table

    2. This should each time when a Boolean value is true.

    3. the table building function should wait 6 s before storing in the table when the value is true

    My problem is that when I press True, and I start changing the starting value (say 0) desired value I want that it either (say 5) before six seconds pass, the value passed to the table after 6 seconds is the starting value of 0 not the value of dessired 5. This value appears the next time that I push the real button.

    It drives me crazy

    And the desired value must come within a structure of sequence because of the structure of the main VI (this is just an excerpt of this cose)

    HELP Please!

    Probably, this should solve your problem.

  • Why the values in a table get deleted once completed VI?

    I have a weird problem with my code. I have a 2D array that receives the data via a connection series microcontroller. My VI search this table for a specific value, and when this value is found, it goes to another part of the code. The problem is that when I run the VI mulitple without closing times, the data in the table not get deleted so the value resulting in the VI move is immediately and the first part of the VI is ignored.

    I have to do something to ensure that all data are deleted after a full run?

    Thank you

    Without seeing a VI, we can only guess.

    My guess is that your code uses shift registers and these shift registers are not initialized.

  • Read integer values to worksheet and display the values in a table

    Hi all

    I have integer values to read from a worksheet and display them in a table. I uses 'Reading of the spreadsheet file' mode 'integer '. I want to display these values in a table. The problem is the table takes only 2d-array of string as input but not an integer.

    It works fine if I change 'Worksheet file playback' mode to 'integer' to 'chain', but I want to read integers and must use integer values for calculations more. Please give suggestions on the display of integers to a table.

    Thank you.

    Do not take not piece-by-piece just convert as a whole. See the attached example

    Good luck

  • Validation form column against the value of another Table

    Hello

    I'm new to this forum, so please bear with me a bit!  I only have a small amount of writing PL/SQL experience, and I've never written Javascript or JQuery before.  I am an Oracle DBA and I coding experience C and PERL, so I have a strong technical background.  But I need some advice on the best way to approach a problem.

    I have an application of data base in Oracle Apex (version 4.2) with a tabular form on a table: Let's say that #1 with the conditions of licence 1 a, 1 b, and1C.  I have to make sure that the value entered in col B is not greater than the value of a column in another table (for example table #2 pass 2 (a).  From a conceptual point of view, the amount of money available is in the #2 table, and my tabular form lines are an act of spending money (such as orders or invoices), so I have to make sure that we spend more that we have.  Who is?

    Does anyone have tips for the best way to do it?  I'm figuring that the biggest problem here is perhaps to account for people who enter multiple lines in the form of tables at the same time, right?  So, if a person is entered 3/invoices, I need a total to ensure that they do not have spend more than we have in the #2 table.

    I really appreciate your help!

    Best regards

    Laurie Baublitz

    Ah, I was not totally with you on this charge then. My validation works overall, but it totals the amount for each line, regardless of the task. Okay - who was not totally my solution but more a demonstration of the technique that you can use to validate your tabular presentation in this way.

    You could solve this issue with a safe collection, or with a table plsql where you add an entry for each task name and keep the amount stored in there.

    Anyway, it would be better for you to spend a little time on playback on the plsql collections or collections apex!

    Remember, this is a sample and you will need to take stock of it. The best solutions are those where you need to experiment with 8)

    DECLARE
      TYPE tt_taskamount IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
      t_taskamount tt_taskamount;
    
      l_task VARCHAR2(20);
      l_amount NUMBER;
      l_max NUMBER;
    BEGIN
      -- F02 is the taskname
      -- F03 is the amount
      -- adapt to your situation!
      FOR i IN 1..apex_application.g_f02.count
      LOOP
        l_task := apex_application.g_f02(i);
        l_amount := apex_application.g_f03(i);
        IF NOT t_taskamount.exists(l_task) THEN
          t_taskamount(l_task) := l_amount;
        ELSE
          t_taskamount(l_task) := t_taskamount(l_task) + l_amount;
        END IF;
    
        -- it's not the best idea to perform a select each time and could be
        -- done better but for the sake of the example it's fine
        -- not too bad either if the rowcount is small.
        SELECT maxamount
          INTO l_max
          FROM table2
         WHERE taskname = l_task;
    
        IF t_taskamount(l_task) > l_max THEN
          -- returning will stop further processing and throw an error message as soon as a budget has been overrun
          -- it might or might not be required behaviour but that's up to you
          RETURN 'The max amount ('||l_max||') for task ' || l_task ||' has been exceeded. Reduce the total amount on associated tasks!';
        END IF;
      END LOOP;
    END;
    
  • Dynamic action based on the value in a table

    Greetings,

    I would like to use a dynamic action to disable a button depending on the value selected/entry in a field in tabular form. Thus, for example, if someone enters the value "LKSG", then a button is disabled (in this case, the 'Add Row' button).

    How I would do this using the tools of dynamic measurements? When I create a dynamic action, I see that my choice of Type 'selection' for dynamic action of shooting is point, area, button, object DOM, jQuery Selector. I don't know how to use a field in a presentation of tabular to firing. Or if it is possible.

    I use APEX version 4.1.1.00.23

    Thanks in advance!

    John

    jfosteroracle wrote:
    Tom - it's very useful! A few questions:

    -J' use a 'button of the model '. To use the static code for the button, I see that the model must include the #BUTTON_ID # in the model. I added the #BUTTON_ID # in the template like this:

    #LABEL#

    Where is the the BUTTON_ID should go, in the

    ?

    After adding this, it does not for a button of the model. But if I change the touch of a button HTML, your method works great!

    It is of course the difference between the two buttons: how they react and, above all, how they are marked upward. An HTML button is a real