the minimum value of two calculated columns column

Hi all

Please, help me in the following scenario.

I have to get the data in two tables, so whatever the columns I need to put it in the select statement, but I have to do the calculations for two columns, and assigned an alias to these two calculated columns name, lets say X & Y.

I need to show the data in column Z, the rule for this column must have a minimum value of columns X and Y.

I have to use only a select statement and retrieve the data. Camnt make changes or creating features on the database.

Thnaks in advance.

Use a view inline and function LESS.

http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/queries007.htm#SQLRF52357

http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions087.htm#SQLRF00657

Tags: Database

Similar Questions

  • PARTITION OF? Returns an identifier based on the minimum value of another column

    Hi guys

    I want to return the ID column of a line, where 2 other columns = a value set, and a 3rd column has the minimum value corresponding to the other criteria.

    so, indeed:

    with t as (
    select 1 dst_id, 'abc' dst_title, 1 edition_from, 1 media_item from dual 
    union all 
    select 2 dst_id, 'abc' dst_title, 1 edition_from, 2 media_item from dual 
    union all 
    select 3 dst_id, 'abc' dst_title, 2 edition_from, 1 media_item from dual 
    union all 
    select 4 dst_id, 'abc' dst_title, 2 edition_from, 2 media_item from dual 
    union all 
    select 5 dst_id, 'def' dst_title, 1 edition_from, 1 media_item from dual 
    union all 
    select 6 dst_id, 'def' dst_title, 1 edition_from, 2 media_item from dual 
    )
      select dst_id
      from t
      where dst_title = 'abc' 
      and edition_from = 1
      and media_item = minimum value of media item using above where clause
    Return dst_id = 1 because it has the value point minimum media 1 where dst_title = abc and edition_from = 1

    Is this possible in 1 query? I tried using partition and on dst_title, edition_from, but it does not work.

    I am currently using a query sub or 2 queries, but think that there must be a way to do it in a?

    Thank you all

    Scott

    pus

    with t as (
      select 1 dst_id, 'abc' dst_title, 1 edition_from, 1 media_item from dual union all
      select 2 dst_id, 'abc' dst_title, 1 edition_from, 2 media_item from dual union all
      select 3 dst_id, 'abc' dst_title, 2 edition_from, 1 media_item from dual union all
      select 4 dst_id, 'abc' dst_title, 2 edition_from, 2 media_item from dual union all
      select 5 dst_id, 'def' dst_title, 1 edition_from, 1 media_item from dual union all
      select 6 dst_id, 'def' dst_title, 1 edition_from, 2 media_item from dual
    )
    select min(dst_id) keep (dense_rank first order by media_item) as dst_id
    from t
    where dst_title = 'abc'
    and edition_from = 1
    ;
    
  • Error when setting the minimum value of entry number Spin Box...

    Hai
    I drag and drop a VO and created a table. In this table, I cast a column that contains an InputText field to entry number Spin Box. During loading of the page, the table retrieves data from the database and display of numerical values in the SpinBox.After who, when I scroll the table through vertical scroll bar, the table * "data extract" * and error began as * "the value must be the number" *... In the original Version, this attribute is a number.
    THIS ERROR will PRODUCT ONLY when I put the minimum value of the counter... The purpose of minimum value, I want only the user to select the value of ve only... How can I prevent the user to select only values of ve... ? (IE, * how to set the minimum value of counter?) *

    Try changing the data type of your attribute in the EO to be Double instead of number.

  • What is the minimum value for the data type double?

    ... a more academic question: what is the minimum value of the data type double? I thought 'double', it is the 8-byte IEEE standard and what I remember, it's + - 1.7E + - 308.  The more different number of 0 should be 1.797E - 308.

    This is why I was a little surprised when I looked at the data output of my calculation of CVI, where I found the numbers with exponents of E-319 or E-324 as the smallest value...

    But I'm sure there's an explanation :-)

    Thank you for sharing with me,

    Wolfgang

    The largest number is indeed the order of + 1.7E + 308; There are a smaller number of - 1.7E + 308. Note that this is in fact the most negative number, which is the smallest by some reckoning. For the small beach of the Exhibitor, things get a little more complicated. 1E-308 can be represented with complete accuracy and resolution, but if you're willing to lose a few bits of precision, you can go down even further. For example:

    Double x, y, z:

    x = 1E-300;

    y = 1E7;

    z = x / y;               Give 1.000000000000000E - 307

    y = 1E8;

    z = x / y;               Give 9.999999999999999E - 309

    y = 1E18;

    z = x / y;               Give 9.999987484955998E - 319

    y = 1E23;

    z = x / y;               Give 9.881312916824931E - 324

    So, as you can see, values less than 1E-308 are possible, but they become increasingly more inaccurate and should not be relied upon.

    JR

  • Take the minimum value for table data

    I'm storing test data in a table, with the hope that I can output the minimum value of the data. So far, I have used the table of max/min but can't make it work how I want. The test runs continuously in a loop of the holder. I get the minimum values in the table, but I would like to change the number of samples that the table contains, before it generates a minimum. The other option is that I run the test for a period of time (e.g. 3 seconds) and the table stores the data for this time then output 1 minimum value for the entire period.

    My current configuration VI is attached.

    Very appreciated

    Chris

    The size of the array in your VI is determined by the number of samples that you collect in your DAQ assistant, who is now 100 samples.  Never more, never less.

    How many samples do you want before you determine the minimum?

    Maybe what you really want to do is to build the table in the while loop and store it in a shift register, and when the loop has repeated enough times, then you take the minimum of built table.

  • Find the minimum value of the table in time...

    Firstly that it is not "find the min value in the table.

    It is:

    I have a table that changes its values at each iteration, and I want to compare the new values with previous values and make a new array with the minimum values...

    In C++, it would be like this:

    int main() {}

    int array [8];

    int min [8];

    int i;

    for (i = 0; i<>

    min [i] = 1000000; Initialize minimum table with a high value

    }

    {while (1)}

    Array = update_array ();

    for (i = 0; i<>

    If (array [i]<>

    min [i] = array [i];

    }

    }

    do things...

    }

    return 0;

    }

    IM new to labview and it always confuses me a lot...

    Thanks in advance.

    Using the function Max & Min regular (not table Max & min as you know) with tables and a good will of employment registry change.  Max Min &, as most of the digital functions, is polymorphic and works witt tables as well as scalars.

    Lynn

  • How to add the full value of two buttons?

    How to add the full value of two buttons (any key) VI and display it in the output text box? I am attaching a sample program, but I know that his evil... Help, please

    Try this

  • Virtual Storage Manager - startTime does not meet the minimum value of 0 error

    Hello

    Someone at - it a fix for the problem in the region related to programming?

    When you attempt to add or change a schedule, we get the following error.

    Title: Too small
    Text: startTime does not meet the minimum value of 0

    What another user has said there US no customer impact and workaround has been to change the region of the computer you were using. I tried this and it doesn't work.

    This error is now a few years old.

    For anyone having this problem, add a parameter string regional en_US to the URL.

    For example .../vsphere-client/?locale=en_us

    Schedules can now be modified properly.

    Here's hoping for a permanent solution in the next major release.

  • values based on the following logic 'values after the first values of two '_' and before last '_' values '.

    Hi all

    I need the values according to below 2logics in a single select query using instring and substring

    1 values based on the following logic 'values after the first values of two '_' and before last '_' values '.

    2 values based on the following logic 'values after the first values of two '_' and before last'-'values '.

    EXM:

    Entry: ABCD_EFGH_IJKLM - NOPQ_XYZ output: IJKLM - NOPQ

    Entry:. ABCD_EFGH_IJKLM - NOPQ output:IJKLM

    Thank you.

    Check the following

    WITH DATA1 AS

    (SELECT "ABCD_EFGH_IJKLM - NOPQ_XYZ" double val)

    UNION ALL

    SELECT 'ABCD_EFGH_IJKLM - NOPQ' double val

    )

    SELECT SUBSTR (VAL, INSTR(VAL,'_',1,2) + 1, DECODE (BIGGER (INSTR (VAL, '_',-1, 1), INSTR(VAL,'-',-1,1)), INSTR (VAL,'-', - 1, 1), LENGTH (VAL) + 1, INSTR (VAL, '_',-1, 1))-(INSTR (VAL, '_', 1, 2) + 1))

    OF DATA1;

    Concerning

    Salim

  • PL/SQL loop to find the minimum value

    I want to find the minimum value from a table using the pl/sql loop

    I have data format below.

    1 ABC 2

    1 ABC 20

    1 ABC 500

    1 ABC 2000

    XYZ 2 250

    JKL 3 300

    MNP 3 350

    3 KLM 400

    I wrote the code below. His does not work. Please suggest.

    Set serveroutput on
    declare
    x number: = 3;
    y VARCHAR2 (3): = 'ABC ';
    fmin number: = 0;
    number of Fmax: = 0;
    Start
    for rec in (select sal from test
    where id = name and x = y) loop


    If rec.sal > fmin then
    fmin: = rec.sal;
    on the other
    FMAX: = rec.sal;
    fmin: = fmax.
    end if;
    end loop;
    dbms_output.put_line (Fmax);
    end;
    /

    I want to output 2 on top of code.

    Thanks in advance

    Why PL/SQL? SELECT MIN (SAL) OF TEST will be more rapid and much less coding. In any case:

    declare

    number of v_min_sal;

    Start

    for v_rec in a loop (select sal from emp)

    If nvl (v_min_sal, v_rec.sal + 1) > v_rec.sal

    then

    v_min_sal: = v_rec.sal;

    end if;

    end loop;

    dbms_output.put_line (' lowest salaray is "' |") v_min_sal | '"');

    end;

    /

    The lowest Salaray is "800".

    PL/SQL procedure successfully completed.

    SQL >

    SY.

  • SQL-MIN() don't not returns the minimum value

    This is my code;

    $SQLx = "SELECT MIN (price_from) AS minimumprice FROM AN_pricetable WHERE accomm_id =". "." $db_field ["accomm_id"];

    $resultx = mysql_query ($SQLx);

    $pricefrom = mysql_result ($resultx, $i, 'minimumprice');

    If ($pricefrom == 0) {}

    $pricefrom = 'TBC' ;}

    But for some reason, it is not the minimum value "price_from". For example, several rows in the table have the same "accomm_id", and their values in the field 'price_from' are: 8, 12, 50-7, but the SQL code returns the MIN 12. What I'm doing wrong here?

    Thank you

    What is the data type of price_from?  If it is a type of string (char), then 12 would be the lowest value.

  • calculation between two columns that depends on the minimum value

    I have the table with the following values, how can auto calculation based to a minimum value to assign each line then?

    Seq 1 reference ID price price of the difference % of difference
    131500
    233500
    334000


    calculation logic

    SCREEN.png


    the result should be...

    Seq 1 reference ID price price of the difference % of difference
    13150000
    23350020001.333
    33400025001,666

    Dev environment

    service of Cloud Computing by oracle

    PRODUCT VERSION STATUS
    NLSRTL11.2.0.3.0Production
    Oracle Database 11g Enterprise Edition11.2.0.3.064 bit Production
    PL/SQL11.2.0.3.0Production
    AMT for Linux:11.2.0.3.0Production

    with

    a_table as

    (select 1 seq_1, 3 ref_id, 1500 Union double all the)

    Select 2,3,3500 from all the double union

    Select double 3,3,4000

    )

    Select seq_1, ref_id, price,

    price - min (price) on differece_price (partition by ref_id by seq_1 order),

    price / min (price) over (partition by seq_1 order ref_id) - 1 difference_percent

    of a_table

    SEQ_1 REF_ID PRICE DIFFERECE_PRICE DIFFERENCE_PERCENT
    1 3 1500 0 0
    2 3 3500 2000 1.33333333333333333333333333333333333333
    3 3 4000 2500 1.66666666666666666666666666666666666667

    Concerning

    Etbin

  • Add up the values from two numeric columns on RTF model

    Hello

    I'm trying to add up the values of the numeric column 2.

    I tried..? column_1 and column_2? > but it's not as simple as that obviously I get an error when you try to do

    I tried..? sum (current - group () / column_1) + sum (current - group () / column_2)? >, but who does no more work that it also returns an error


    Any ideas how to add two numeric columns in RTF model?

    for 2 + 3

     
    
  • How to highlight the minimum value in a column?

    I need to highlight the lowest value in each column in my spreadsheet. I try to use the conditional nail, but I can't find a function to work as I need.

    One way would be to calculate the minutes in a cell of a footer row, select the cells in the body of the column and apply conditional highlighting like this:

    You must click on the chip address first, and then select the comparison cell, A8 here, then be sure to keep the row and column.

    The A8 from the example formula is = MIN (A).

    The result is a bold 2 (not shown in the screenshots).

    SG

  • Get the cumulative values in a single column based on another column in reports

    Hi all

    I have a requirement to get cumulative values based on another column.
    I 'Sales rep name' in the first column.
    Correspondent "Values of the invoice line" in the second column.
    Want to have cumulative of all the values for each sales invoice line.
    Then apply rank and display the top 10 sales reps based on invoice lines.
    Since there is no rank option in the PivotTable, I do this in the report table.

    Looking for the best entries...

    Thanks in advance...

    Try below
    2nd column: "name of Sales rep.
    column 2: SUM ("invoice line values ' BY 'Name of Sales rep'") and sort this field desc.
    3rd column: fx RANK (SUM ("invoice line values" BY "Sales rep name")), to hide this column, so that you don't confuse your users.

    and put the filter on the 3rd column below 5

    I hope this works for you

Maybe you are looking for

  • Question about the installation of the driver on Satellite L20-153 PSL2XE

    Hi, a friend gave me his system Satellite L20 to install XP Pro SP2 (System was originally shipped with XP Home). After installation of XP Pro SP2, I tried to install the driver from the chipset of the page of the driver from the site, but I kept rec

  • Explorer and USB Autostart key Diasbling

    Hello I'd like to Windows not to launch an Explorer when you insert a USB key or drive. Automatic Diasbling begins in the properties of the device is not enough. Y at - it a key of registry to set or something else? Thank you for the answers.

  • Activation of the operating system failure:

    Re-loaded OS (Vista Home typo) of re-covery disk to new HD product code back embedded code invalid, I tried to tag on computer and stops 1/2 way through entering with "Invailed characuter.

  • Components layout

    Hello I have 3 grids on my screen. I want that little space between them. How do I get it. private GridFieldManager setupGrid(int grid) { GridFieldManager gfm = new GridFieldManager(new int[] {110, 150, 50}, 110, 0); gfm.setBackground(BackgroundFacto

  • The BBM browser history is visible on the phone to contacts

    Evening all, I seem to have a problem hunting in a setting that stops my history of browser that appear on my wife's iPhone. I use Q10 10.2.1.2102 operation and it is running the latest version of the iOS with the latest version of bbm. Somehow she m