Optimized query to find Min and max of a col in a table

I have a table doc_boe_rec with record count 12375934
the primary key columns are (boe_rec_id,psd_serial_num).
No other ndexes are present on this table.
I want an optimized query which will give both the results :
1.Min boe_rec_id (boe_rec_id from 1st record)
2.Max boe_rec_id from this table with rows limited to a value say 5000.
i.e (boe_rec_id from 5000th column value from table )
Thanks
Manoj

1.Min boe_rec_id (boe_rec_id from 1st record)It is confusing for me. The min value for the first, hmmm...
2.Max boe_rec_id from this table with rows limited to a value say 5000.Not more clear...
Please details your requirements.
Nicolas.

Similar Messages

  • Find min and max from a bunch of numbers

    hi,
    i have a bunch of numbers, and i need to find the min and max.
    so i have a arraylist which contains objects....whats the best way to find the min number and max number of all these objects?
    thanks

    You're close, but you can do them all at the same time without temp variables..
    double maximumX = 0;
    double minimumX = 0;
    double maximumY = 0;
    double minimumY = 0;
    for (int i = 0; i < myobjects.size(); i++) {
         mything d2d = (mything) myobjects.get(i);
         maximumX = Math.max(d2d.getBounds().getMaxX(), maximumX);
         minimumX= Math.min(d2d.getBounds().getMinX(), minimumX);
         maximumY = Math.max(d2d.getBounds().getMaxY(), maximumY);
         minimumY = Math.min(d2d.getBounds().getMinY(), minimumY);
    }Since you are dealing with rectangles, you could add them all to an Area and get the bounds of the Area, but that's probably slower.

  • How to find min and max of a field from sorted internal table

    Hi,
    I have sorted Internal Table by field f1.
    How do I find max and min value of f1.
    For min value of f1 I am using,
    READ TABLE IT1 INDEX 1.
    IT1-F1 = MIN.
    Is this correct? And how do I find the max value of f1 from this table.
    Thanks,
    CD

    Yes, that is right, and you can get the max like this.
    data: lv_lines type i.
    * get min
    READ TABLE IT1 INDEX 1.
    MIN  = IT1-F1.
    * get max
    lv_lines = lines( it1 ).
    read table it1 index lv_lines.
    MAX  = IT1-F1.
    Regards,
    Rich Heilman

  • Finding Min and Max

    I have the following data stored in java. The names are stored as a 1 dimensional array and the figures as a 2 dimensional array.
    -----------------------------Min Max
    Joe Jones 32 22 20 10 ? ?
    Jim Long 10 45 10 60 ? ?
    Tom Doon 5 10 50 70 ? ?
    What I want to do is to find the Mininum and Maximum value of each row. It would be displayed where the question ,marks are. What should my code be???

    you can use the sort method to determine which is the max/min and then return them & still keep your list as is.
    something like:
    -----------------------------Min Max
    Joe Jones 32 22 20 10 sort.getMax() sort.getMin()
    Jim Long 10 45 10 60 ? ?
    Tom Doon 5 10 50 70 ? ?
    for the getMax() method - return the last element in the sorted array
    for the getMin() method - return the first element in the sorted array

  • Query to group min and max times

    Can anyone please tell me how to write the followinf query?
    USER DATE MIN_TIME MAX_TIME
    ASMITH 01/01/2000 06:01:01 17:01:01
    ASMITH 02/01/2000 06:08:01 17:06:01
    ASMITH 03/01/2000 06:01:01 17:01:01
    STIGER 01/01/2000 06:01:01 06:01:01
    I have 2 columns: USER and WORK_DATE
    I want to return the min(time) max(time) grouped per day and user.
    So for every user I want the start time and end time for everyday.
    Thanx

    select user, date, min(time), max(time)
       from table
    group by user, date
    Can anyone please tell me how to write the followinf query?
    USER DATE MIN_TIME MAX_TIME
    ASMITH 01/01/2000 06:01:01 17:01:01
    ASMITH 02/01/2000 06:08:01 17:06:01
    ASMITH 03/01/2000 06:01:01 17:01:01
    STIGER 01/01/2000 06:01:01 06:01:01
    I have 2 columns: USER and WORK_DATE
    I want to return the min(time) max(time) grouped per day and user.
    So for every user I want the start time and end time for everyday.
    Thanx

  • Best Way to find min and max

    Hi
    I wish to know is there any better way to get min(zseq) from a query statement?
    I have data as :
    00010 10 1 10/10/2006   - need to get tihs date (min)
    00010 10 2 12/10/2006
    00010  10 3 15/10/2006 - need to get this date(max-1)
    00010 10 4 18/10/2006 - need to get this date (max)
    My query :
    SELECT ZCDD FROM ZVI2D INTO S_1ST_ZCDD
          WHERE ZVBELN = WA_OUTPUT_ALL-VBELN AND ZPOSNR = WA_OUTPUT_ALL-POSNR
            AND ZSEQ IN ( SELECT MIN( ZSEQ ) FROM ZVI2D WHERE ZVBELN = WA_OUTPUT_ALL-VBELN AND ZPOSNR = WA_OUTPUT_ALL-POSNR ).
             AND ZDATUM = WA_OUTPUT_ALL-ZDATUM ).
        ENDSELECT
    I will reward points if you are able to give a good uggestion. Thanks.

    i think you can get max and min from the select query itself just check my previous posting for the min. But i dont think you can get the second maximum value from the select query. For that you have to store the data in itab and sort that by descending read thae table itab with index 1(max) and index 2(second largest) and last for min.
    suppose you have data inyour itab.
    data : lin type i.
    sort itab by <field name> descending.
    read table itab index 1."for max value.
    write : / itab-<field>.
    read table itab index 2."second largest.
    write : / itab-<field>.
    describe table itab lines lin.
    read table itab index lin.
    write :  / itab-<field>.
    regards
    shiba dutta

  • Finding Min and Max date

    SELECT * FROM (
    SELECT 'STOR_A' STORE_NAME ,'BX1' BOX_NO, 'X11' LOC, '01-JAN-2010' MOVE_DT FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX1' , 'X21' , '03-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX1' , 'X13' , '05-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX1' , 'X41' , '07-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX1' , 'X15' , '09-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX2' , 'X31' , '02-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX2' , 'X71' , '04-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX2' , 'X18' , '06-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX3' , 'X91' , '04-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX3' , 'X10' , '05-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX3' , 'X14' , '07-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX3' , 'X51' , '10-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_A'  ,'BX3' , 'X16' , '12-JAN-2010'  FROM DUAL UNION ALL 
    SELECT 'STOR_B'  ,'BX2' , 'X41' , '09-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_B'  ,'BX2' , 'X74' , '11-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_B'  ,'BX2' , 'X31' , '12-JAN-2010'  FROM DUAL UNION ALL
    SELECT 'STOR_B'  ,'BX2' , 'X68' , '17-JAN-2010'  FROM DUAL
    [pre/]
    I have the data of the Boxes which came to the store and changed the locations on a date.
    how can i select in a single row the as below. Boxwise the date and location on which received in and sent out
    [pre]
    BOX_NO     STORE_NAME     IN_LOC              IN_DATE          OUT_LOC     OUT_DATE
    BX1     STOR_A          X11          01-Jan-10     X15     09-Jan-10
    BX2     STOR_A          X31          02-Jan-10     X18     06-Jan-10
    BX3     STOR_A          X91          04-Jan-10     X16     12-Jan-10
    BX2     STOR_B          X41          09-Jan-10     X68     17-Jan-10
    [pre/]
    Can someone helpout from the query                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    using aggregate keep first/last functions:
    with my_tab as (SELECT 'STOR_A' STORE_NAME ,'BX1' BOX_NO, 'X11' LOC, to_date('01-JAN-2010', 'dd-MON-yyyy') MOVE_DT FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX1' , 'X21' , to_date('03-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX1' , 'X13' , to_date('05-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX1' , 'X41' , to_date('07-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX1' , 'X15' , to_date('09-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX2' , 'X31' , to_date('02-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX2' , 'X71' , to_date('04-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX2' , 'X18' , to_date('06-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX3' , 'X91' , to_date('04-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX3' , 'X10' , to_date('05-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX3' , 'X14' , to_date('07-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX3' , 'X51' , to_date('10-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_A'  ,'BX3' , 'X16' , to_date('12-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL 
                    SELECT 'STOR_B'  ,'BX2' , 'X41' , to_date('09-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_B'  ,'BX2' , 'X74' , to_date('11-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_B'  ,'BX2' , 'X31' , to_date('12-JAN-2010', 'dd-MON-yyyy')  FROM DUAL UNION ALL
                    SELECT 'STOR_B'  ,'BX2' , 'X68' , to_date('17-JAN-2010', 'dd-MON-yyyy')  FROM DUAL)
    select box_no,
           store_name,
           min(loc) keep (dense_rank first order by move_dt) in_loc,
           min(move_dt) in_date,
           max(loc) keep (dense_rank last order by move_dt) out_loc,
           max(move_dt) out_date
    from   my_tab
    group by box_no,
             store_name
    order by store_name, box_no;
    BOX STORE_ IN_ IN_DATE             OUT OUT_DATE
    BX1 STOR_A X11 01/01/2010 00:00:00 X15 09/01/2010 00:00:00
    BX2 STOR_A X31 02/01/2010 00:00:00 X18 06/01/2010 00:00:00
    BX3 STOR_A X91 04/01/2010 00:00:00 X16 12/01/2010 00:00:00
    BX2 STOR_B X41 09/01/2010 00:00:00 X68 17/01/2010 00:00:00Edited by: Boneist on 29-Jul-2010 14:32
    Oh darn it! Too slow! {noformat}*pootles off for more caffeine*{noformat}

  • Performance Issue using min() and max() in one SQL statement

    I have a simple query that selects min() and max() from one column in a table in one sql statment.
    The table has about 9 Million rows and the selected column has a non unique index. The query takes 10 secs. When i select min() and max() in separate statements, each takes only 10 msecs:
    This statement takes 10 secs:
    select min(date_key) , max(date_key)
    from CAPS_KPIC_BG_Fact_0_A
    where date_key != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
    This statement takes 10 msecs:
    select min(date_key)
    from MYTABLE
    where date_key != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
    union all
    select max(date_key) from MYTABLE
    Because the first statement is part of an autmatic generated SQL of an application, i can't change it and i have to optimize the data model. How can i speed up the first statement?

    I've ran similar query on a table that has 10 milliion rows, with an index on the date column
    This is what I have found:
    SQL> set timing on
      1  SELECT MIN(ID_DATE) MIN_DATE, MAX(ID_DATE) MAX_DATE
      2      FROM MY_DATE
      3*     WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
    SQL> /
    MIN_DATE  MAX_DATE
    03-APR-76 06-JAN-02
    real: 43383
    SQL> SELECT MIN(ID_DATE) MIN_DATE FROM MY_DATE
      2   WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
      3  UNION ALL
      4  SELECT MAX(ID_DATE) MAX_DATE FROM MY_DATE
      5   WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD'))
      6  /
    MIN_DATE
    03-APR-76
    06-JAN-02
    real: 20
    SQL> SELECT MIN_DATE, MAX_DATE FROM
      2  (SELECT MAX(ID_DATE) MAX_DATE FROM MY_DATE
      3  WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD')) ) A,
      4  (SELECT MIN(ID_DATE) MIN_DATE FROM MY_DATE
      5  WHERE ID_DATE != TO_DATE(('1900-1-1' ),( 'YYYY-MM-DD')) ) B
      6  /
    MIN_DATE  MAX_DATE
    03-APR-76 06-JAN-02
    real: 10
    SQL> My conculsion, there is nothing you can do to the tables that will improve that particular statement.
    Why can't you modify the application?

  • Find more than one min and max in 2D array contain 0 rows

    Hi
    I have a 2D array and I would like to find the max and min elements between series of 0s. As you can see in the picture If I remove all 0s from the array and use the max and min function then I will have just one min and one max but I need to find min and max after every 0 rows so you can see from the picture ( just as an example) I will have 3 min and 3 max numbers. Would you please help me with this code. Do you now any algorithm that can find min and max between 0s?
    I have also attached my code to remove 0s and then search for max and min numbers but as I mentioned I need min and max for every part
    Many thanks
    Attachments:
    2.jpg ‏82 KB
    3.jpg ‏27 KB

    Thanks altenbach
    I have attached the vi to this post. I would really apperciate if you help me with this example. The min values should be 100, 1500 and 4000 and the max values should be 1200,2600,5400 so as u mentioned the output should be this 2D array 
    100,1200
    1500,2600
    4000,5400
    Attachments:
    new.vi ‏6 KB

  • Query about min and max and middle row of a table

    suppose i have table emp and field
    v_date date;
    which has data in time stamp
    time
    10:20
    10:25
    10:30
    10:32
    10:33
    10:35
    10:36
    10:38
    I need only min time and max time and two record between min and max

    I need only min time and max time and two record between min and max Like this?
    SQL> create table t (id number);
    Table created.
    SQL>
    SQL> insert into t values (1020);
    1 row created.
    SQL> insert into t values (1025);
    1 row created.
    SQL> insert into t values (1030);
    1 row created.
    SQL> insert into t values (1032);
    1 row created.
    SQL> insert into t values (1033);
    1 row created.
    SQL> insert into t values (1035);
    1 row created.
    SQL> insert into t values (1036);
    1 row created.
    SQL> insert into t values (1038);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select * from t;
         ID
       1020
       1025
       1030
       1032
       1033
       1035
       1036
       1038
    8 rows selected.
    SQL>
    SQL>
    SQL> select decode(rownum, 1, min_val, 4, max_val, next_val) your_data from (
      2  select first_value (id) over (partition by 'a' order by 'a') min_val,
      3         last_value (id) over (partition by 'a' order by 'a')  max_val,
      4         id,
      5         lead(id) over (partition by 'a' order by id) next_val
      6   from t
      7  order by id
      8   )
      9  where min_val <> next_val and max_val <> next_val
    10  and rownum <= 4;
    YOUR_DATA
         1020
         1030
         1032
         1038
    SQL>

  • To find out the min and max memory been used by each parameter under SGA_MA

    Hi,
    Can any please tell me how to find out the min and max memory been used by each parameter under SGA_MAX and SGA_TARGET ? below is the db CRMS65T. If any such script is there please provide me
    SQL> select name from v$database;
    NAME
    CRMS65T
    SQL> show parameter sga
    NAME                                 TYPE        VALUE
    lock_sga                             boolean     FALSE
    pre_page_sga                         boolean     FALSE
    sga_max_size                         big integer 1000M
    sga_target                           big integer 1000MThanks in advance

    Can any please tell me how to find out the min and max memory been used by each parameter under SGA_MAX and SGA_TARGET ? below is the db CRMS65T. If any such script is there please provide meI guess your question is, each memory components of SGA? if so
    SQL> select * from v$sgainfo;
    NAME                                  BYTES RES
    Fixed SGA Size                      2088504 No
    Redo Buffers                       18882560 No
    Buffer Cache Size                 616562688 Yes
    Shared Pool Size                  301989888 Yes
    Large Pool Size                     4194304 Yes
    Java Pool Size                      4194304 Yes
    Streams Pool Size                         0 Yes
    Granule Size                        4194304 No
    Maximum SGA Size                  947912704 No
    Startup overhead in Shared Pool   125829120 No
    Free SGA Memory Available                 0Also check
    SQL> select COMPONENT,CURRENT_SIZE,MIN_SIZE,MAX_SIZE,USER_SPECIFIED_SIZE from v$sga_dynamic_components;
    shared pool                                                         301989888  301989888          0           209715200
    large pool                                                            4194304    4194304          0             4194304
    java pool                                                             4194304    4194304          0             4194304
    streams pool                                                                0          0          0                   0
    DEFAULT buffer cache                                                616562688  616562688          0           603979776
    KEEP buffer cache                                                           0          0          0                   0
    RECYCLE buffer cache                                                        0          0          0                   0
    DEFAULT 2K buffer cache                                                     0          0          0                   0
    DEFAULT 4K buffer cache                                                     0          0          0                   0
    DEFAULT 8K buffer cache                                                     0          0          0                   0
    DEFAULT 16K buffer cache                                                    0          0          0                   0
    DEFAULT 32K buffer cache                                                    0          0          0                   0
    ASM Buffer Cache                                                            0          0          0           603979776
    13 rows selected.
    SQL>Edited by: CKPT on Sep 19, 2011 8:55 AM

  • MIN and MAX datetimes ti find  range

    I am using Oracle 11g version
    create table re(Name char(20),Datetime char(45),val1 number);
    insert into re values('abc','10/29/2012 13:00','1.5')
    insert into re values('abc','10/29/2012 13:05','1.5')
    insert into re values('abc','10/29/2012 13:10','1.5')
    insert into re values('abc','10/29/2012 13:15','1.5')
    insert into re values('abc','10/29/2012 13:20','0.00')
    insert into re values('abc','10/29/2012 13:25','0.00')
    insert into re values('abc','10/29/2012 13:30','0.00')
    insert into re values('abc','10/29/2012 13:35','0.00')
    insert into re values('abc','10/29/2012 13:40','2.1')
    insert into re values('abc','10/29/2012 13:45','2.3')
    insert into re values('abc','10/29/2012 13:50','2.1')
    insert into re values('abc','10/29/2012 13:55','2.1')
    insert into re values('abc','10/29/2012 14:00','2.2')
    O/P:
    In this way data is stored in database.Needed output is, I want the datetime column data range with min and max values where val1>0 only.
    Expected result while we consider the above data is::
    Name mintime maxtime
    abc 10/19/2012 13:00 10/19/2012 13:15
    abc 10/29/2012 13:40 10/29/2012 14:00
    For this I tried something like this,
    select name, min(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) start, max(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) end from (
    select name, Datetime ,to_date(Datetime ,'mm/dd/yyyy hh24:mi') - rank() over (partition by loc_name order by t1 asc) Val_col from re where val1 > 0
    ) group by lname, Val_col
    but I am getting the output like this for above query.
    name start end
    abc 10/29/2012 13:00 10/29/2012 13:00
    abc 10/29/2012 13:05 10/29/2012 13:05
    so.on.
    Edited by: 913672 on Apr 3, 2013 3:07 AM

    913672 wrote:
    I am using Oracle 11g version
    create table re(Name char(20),Datetime char(45),val1 number);
    insert into re values('abc','10/29/2012 13:00','1.5')
    insert into re values('abc','10/29/2012 13:05','1.5')
    insert into re values('abc','10/29/2012 13:10','1.5')
    insert into re values('abc','10/29/2012 13:15','1.5')
    insert into re values('abc','10/29/2012 13:20','0.00')
    insert into re values('abc','10/29/2012 13:25','0.00')
    insert into re values('abc','10/29/2012 13:30','0.00')
    insert into re values('abc','10/29/2012 13:35','0.00')
    insert into re values('abc','10/29/2012 13:40','2.1')
    insert into re values('abc','10/29/2012 13:45','2.3')
    insert into re values('abc','10/29/2012 13:50','2.1')
    insert into re values('abc','10/29/2012 13:55','2.1')
    insert into re values('abc','10/29/2012 14:00','2.2')
    O/P:
    In this way data is stored in database.Needed output is, I want the datetime column data range with min and max values where val1>0 only.
    Expected result while we consider the above data is::
    Name mintime maxtime
    abc 10/19/2012 13:00 10/19/2012 13:15
    abc 10/29/2012 13:40 10/29/2012 14:00
    For this I tried something like this,
    select name, min(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) start, max(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) end from (
    select name, Datetime ,to_date(Datetime ,'mm/dd/yyyy hh24:mi') - rank() over (partition by loc_name order by t1 asc) Val_col from re where val1 > 0
    ) group by lname, Val_col
    but I am getting the output like this for above query.
    name start end
    abc 10/29/2012 13:00 10/29/2012 13:00
    abc 10/29/2012 13:05 10/29/2012 13:05
    so.on.Firstly and most importantly do NOT store dates as char columns: that's what the DATE type is for.
    Secondly, i'm not sure how you get your output from the input, particularly as your SQL contains 'partition by loc_name' which
    doesn't even exist in your example table.
    Why has the same name got two rows with those min/max times. Are you partitioning by val1?

  • Min and Max values from entire table

     Hi,
     i have requirement in which i need to find the min and max values from the entire table.
    See the sample data 
    create table test
    Sal1 int,
    Sal2 int,
    Sal3 int
    insert into test values (100,700,5700)
    insert into test values (200,3300,5300)
    insert into test values (4400,1200,3500)
    insert into test values (5400,5600,3100)
    i want the output as 100 and 5700.. how can i achieve this in a single query. Please through some light on this topic..!
    Thanking you in advance
    Regards,
    Balaji Prasad B
    Balaji - BI Developer

    Below is an example with a subquery for each of the queries Mohammad posted in order to return both min and max in a single result set.
    SELECT ( SELECT MAX(Maxx) AS Maxx
    FROM test UNPIVOT
    ( Maxx FOR E IN ( Sal1, Sal2, Sal3 ) ) AS unpvt
    ) AS Maxx
    , ( SELECT MIN(Minn) Minn
    FROM test UNPIVOT
    ( Minn FOR E IN ( Sal1, Sal2, Sal3 ) ) AS unpvt
    ) AS Minxx;
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • QoS - Min and Max Thresholds

    Hello Everyone,
    I'm studying QoS and I'm wondering how does a Cisco Engineer find out what the best Minimum and Maximum Threshold rates are when using WRED?
    Where would one find these values?
    I'm under the impression that it requires a study that's based on the size of the queues, is that correct?
    But then, I come to the conclusion that even if the queues are big enough, application critical data like (VOIP) would suffer from delay..
    So, how do you calculate the min and max threshold values..
    Thanks ahead of time..
    PR

    Disclaimer
    The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.
    Liability Disclaimer
    In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.
    Posting
    Setting WRED parameters, for optimal performance, is (IMO) very tedious.  Lots of variables involved.
    For starters, it shouldn't normally be applied to traffic that's not rate-adaptive, such as VoIP.
    It works best for multiple large bulk data transfer TCP streams that are using dropped packets for their principle flow control.  Then it can be optimized to maximize their "goodput".
    To answer your question, you might study RED literature, and its many variants, found on the Internet.
    You also want to study, if you're not already very familiar, with how adaptive flow rate protocols, such as TCP, behave when packets are dropped.  (With TCP also be mindful of the different "flavors", i.e. Tahoe, Reno, New-Reno, etc.)
    If you have specific questions, post again to this thread, and I might be able to help.

  • Difference of value of a dimension based on min and max

    Database: Oracle 10g
    BO-BOXIr3
    Let me explain the exact problem again.
    As per the below code, I have the data in this format in my table:
    Code:
    Date              Site ID     KWH
    1/2/2009 00:00     IN-1     22
    1/2/2009 01:00     IN-1     28
    1/3/2009 03:00     IN-2     25
    1/3/2009 04:00     IN-2     46
    1/4/2009 00:00     IN-3     28
    1/4/2009 10:00     IN-3     34
    1/5/2009 08:00     IN-4     31
    1/5/2009 09:00     IN-4     55
    1/5/2009 11:00     IN-4     77
    1/6/2009 00:00     IN-5     34
    Now want to build a report with following columns:
    Site     Count     KWH
    IN-1     2     6 (ex.-28-22)
    IN-2     2     21
    IN-3     2     6
    IN-4     3     46 (ex.-77-31)
    IN-5     2     34
    SITE- distinct site name.
    COUNT-count is number of repetitions of site id between min and max date.
    KWH -(Delta between the min and max date)
    To get the above result I have created 3 report from different queries since not able to get these al in a single report viz Count, Max Value and Min value. Well I have all these 3 reports or table on a single page.
    Count-this report will give the count between the dates
    Max Value-this report will give me the values of kwh for max dates for each site id
    Min Value-this report will give me the values of kwh for min dates for each site id
    Now want to create a single report based on these 3 reports which contains the column
    Site|Count|KWH
    IS IT POSSIBLE?
    Or
    Is it possible to build such report in a single one with all the required column which I mentioned?
    The variables which I created to get the max & min dates,
    Mx_dt= =Max([Query 2].[Hourly]) In ([Query 2].[SITE_ID])
    Mn_dt= =Min([Query 3 (12)].[Hourly]) In ([Query 3 (12)].[SITE_ID])
    For filtering on report used following variables:
    if_st_mn=If([mn_dt])=[Hourly] Then "ok" Else "no"
    if_st_mx =If([mx_dt])=[Hourly] Then "ok" Else "no"
    will filter on "ok" to get the max and min date values.
    rest of the variable in the snap are not usable.

    Yes, you can do it in one report.
    I created a sample report from efashion:
    Year | Lines | Sales Revenue
    2001 | Accessories | $250
    2003 | Accessories | $550
    2001 | City Skirts | $1050
    2003 | City Skirts | $1150...........
    Create 2 variables 1) Count and 2) Difference:
    1) Count  as formula - =Count([Lines]) In Report
    2) Difference as formula - =Sum([Sales revenue]) Where (Max([Year]) In Report = [Year]) - Sum([Sales revenue]) Where (Min([Year]) In Report = [Year])
    You can replace the formula with your report variables. Then just drag Site ID, Count and Difference variables to your report.
    Thanks
    Jai

Maybe you are looking for

  • In monitor I didnt see the receiver

    Hello Friends, Regarding the Enhanced Receiver determination. I am working on the below blog "Illustration of Enhanced Receiver Determination - SP16 I have done the design in IR as below 1) Created two data types (one input,one output) 2)Created resp

  • Integration with other Oracle CRM apps.

    My customer currently uses Oracle CRM On Demand and is looking into the following additional apps from oracle... 1. Sales Prospector 2. Deal Management 3. Sales library 4. Sales Campaigns If purchased, will these applications require any integration

  • Referencing sub templates in the main template

    Hi all, I ve developed a layout which is to be uploaded for print option to be used. But since there can be html tags in the data to be printed, I found a xsl file which has got transformations from html to xslfo. Now I need to include this sub templ

  • Problem downloading photoshop elements 11

    How can I download photoshop - I am getting error message 1935 right at the end of the download and then it reverses all download actions and leaves file empty with no access to the program?  I have tried several times and using both methods of downl

  • Spring 2011 MacBook Pro running Windows 7, burning up

    Hello! My MacBook is doing something really strange. With the lid closed, it wakes itself back up and begins running. The screen remains off; it just runs... without the fans. A few hours ago, I came back to my computer. It had beens sleeping running