2nd greatest values

Hi ,
I'm having three columns with numbers. I have to find first largest,2nd largest and third largest value
Currently i'm using following logic
ley say col 1 =10 col2=4; col3 = 7
1 greatest = greatest (col1,col2,col3) which is 10
3 greated = least (col1,col2,col3) which is 4
2nd greatst = (10+4+7) - (1st greatest - 3rd greatest) which is 7.
Is there any oracle function like greatest,least to find second largest.
Thanks,
Sujeeth

Hi
I thought about the same method, but :
Frank Kulash wrote:
For the special case of finding the 2nd greatest of 3 columns, this will work:
GREATEST ( LEAST (col1, col2)
      , LEAST (col2, col3)
This won't be enough. You have to test both three combinations ab, bc, ca.
See :Scott@my10g SQL>ed
Wrote file afiedt.buf
  1  with t as
  2  (
  3  select 1 a, 2 b, 3c from dual
  4  union all select 6,3,9 from dual
  5  union all select 6,3,1 from dual
  6  union all select 6,17,9 from dual
  7  union all select 12,13,9 from dual
  8  )
  9  select t.*,
10  greatest(least(a,b),least(b,c)) frck,
11  greatest(least(a,b),least(b,c),least(c,a)) secnd
12* from t
Scott@my10g SQL>/
         A          B          C       FRCK      SECND
         1          2          3          2          2
         6          3          9          3          6
         6          3          1          3          3
         6         17          9          9          9
        12         13          9         12         12on the second line : testing only 2 would bring wrong result.
[edit]
One other way +(more explicit)+ would be to test all combinations in a case :case
when (b>a and a>c) or (c>a and a>b)  then a
when (a>b and b>c) or (c>b and b>a)  then b
when (a>c and c>b) or (b>c and c>a)  then c
end secndc

Similar Messages

  • Greatest value

    Hi,
    One of my friend has given this problem to me.
    I'm using 11g.
    Two tables t1, t2. No relation exist between these two tables. Please find the table Scripts below.
    -- Table t1
    CREATE TABLE t1(col1 NUMBER, col2 NUMBER);
    INSERT INTO t1 VALUES (1,2);
    INSERT INTO t1 VALUES (NULL,10);
    INSERT INTO t1 VALUES (3,4);
    INSERT INTO t1 VALUES (89,NULL);
    INSERT INTO t1 VALUES (5,6);
    -- Table t2
    CREATE TABLE t2(col1 NUMBER, col2 NUMBER);
    INSERT INTO t2 VALUES (3,2);
    INSERT INTO t2 VALUES (9,NULL);
    INSERT INTO t2 VALUES (5,4);
    INSERT INTO t2 VALUES (7,6);
    INSERT INTO t2 VALUES (NULL,87);
    COMMIT;
    -- Table Data
    SELECT *
    FROM t1;
            COL1     COL2
         1     2
              10
         3     4
         89     
         5     6
    SELECT *
    FROM t2;
            COL1     COL2
         3     2
         9     
         5     4
         7     6
              87I need to retrieve greatest value from t1 and greatest value from t2 in two seperate columns.
    Expected output:
            RES1          RES2
         2                3
         10              9
         4                5
         89              7
         6               87I was able to select RES1, RES2 individually using below code. But I dont know how to get the same using single SQl statement.
      SELECT  greatest(NVL(t1.col1,0),NVL(t1.col2,0)) res1
      FROM t1Please help me in getting required result from two tables using one SQl query.
    Thanks,
    Suri
    Edited by: Suri on Jul 4, 2012 1:08 AM

    Suri wrote:
    Hi,
    One of my friend has given this problem to me.
    I'm using 11g.
    Two tables t1, t2. No relation exist between these two tables. Please find the table Scripts below.
    -- Table t1
    CREATE TABLE t1(col1 NUMBER, col2 NUMBER);
    INSERT INTO t1 VALUES (1,2);
    INSERT INTO t1 VALUES (NULL,10);
    INSERT INTO t1 VALUES (3,4);
    INSERT INTO t1 VALUES (89,NULL);
    INSERT INTO t1 VALUES (5,6);
    -- Table t2
    CREATE TABLE t2(col1 NUMBER, col2 NUMBER);
    INSERT INTO t1 VALUES (3,2);
    INSERT INTO t1 VALUES (9,NULL);
    INSERT INTO t1 VALUES (5,4);
    INSERT INTO t1 VALUES (7,6);
    INSERT INTO t1 VALUES (NULL,87);
    COMMIT;
    -- Table Data
    SELECT *
    FROM t1;
         COL1     COL2
         1     2
              10
         3     4
         89     
         5     6
    SELECT *
    FROM t2;
         COL1     COL2
         3     2
         9     
         5     4
         7     6
              87I need to retrieve greatest value from t1 and greatest value from t2 in two seperate columns.
    Expected output:
         RES1          RES2
         2                3
         10              9
         4                5
         89              7
         6               87I was able to select RES1, RES2 individually using below code. But I dont know how to get the same using single SQl statement.
    SELECT  greatest(NVL(t1.col1,0),NVL(t1.col2,0)) res1
    FROM t1Please help me in getting required result from two tables using one SQl query.
    Thanks,
    SuriDoesn't really make any sense seeing as how there is no way to join the results. You can make one up as i did below, but without some logical ordering attribute this goes back to making no sense.
    ME_XE?with
      2     data1 as
      3  (
      4     select
      5        greatest(nvl(col1, 0), nvl(col2,0) )   as col1,
      6        row_number() over (order by 1)         as rn
      7     from t1
      8  ),
      9     data2 as
    10  (
    11     select
    12        greatest(nvl(col1, 0), nvl(col2,0) )   as col1,
    13        row_number() over (order by 1)         as rn
    14     from t2
    15  )
    16  select d1.col1 as col1, d2.col1 as col2
    17  from data1 d1 full outer join data2 d2
    18  on (d1.rn = d2.rn);
                  COL1               COL2
                     2                  3
                    10                  9
                     4                  5
                    89                  7
                     6                 87
    5 rows selected.
    Elapsed: 00:00:00.01
    ME_XE?
    ME_XE?Cheers,

  • Getting 2nd Least Value from Different Column

    Hi there All,
    I have one odd requirement.
    I hava table which has diffrent columns of numeric Datatype.
    The task is to get the least values from the table.
    I can take the least value by least(col1,col2,col3 ...) function.Until this stage it is fine.
    But also I have take 2nd least value and 3rd least value, which I am quite unsure how to get it.
    Looking forward for suggestions.
    Thanks in Advance.
    Regards,
    Ajeet

    The following is a generic solution that will allow you to select the nth least and allow you to pass as many column names as you like and will return null if the nth least requested exceeds the number of distinct values. The nleast function that I wrote uses the str2tbl function by Tom Kyte. I have included a demonstration of its usage below. The value returned for the 1st least is the same as that returned by the least function.
    This should have been posted on the SQL and PL/SQL discussion group of these forums, rather than the general database. I also posted the same response in the SQL discussion group of the Orafaq forums.
    scott@ORA92> -- test data:
    scott@ORA92> SELECT * FROM your_table
      2  /
          COL1       COL2       COL3
             1          2          3
             4          6          5
             8          7          9
            11         12         10
            15         13         14
            18         17         16
    6 rows selected.
    scott@ORA92> -- type and functions:
    scott@ORA92> create or replace type myTableType as table of number;
      2  /
    Type created.
    scott@ORA92> create or replace function str2tbl( p_str in varchar2 )
      2  return myTableType
      3  as
      4        l_str      long default p_str || ',';
      5        l_n         number;
      6        l_data    myTableType := myTabletype();
      7  begin
      8        loop
      9            l_n := instr( l_str, ',' );
    10            exit when (nvl(l_n,0) = 0);
    11            l_data.extend;
    12            l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
    13            l_str := substr( l_str, l_n+1 );
    14        end loop;
    15        return l_data;
    16  end;
    17  /
    Function created.
    scott@ORA92> CREATE OR REPLACE FUNCTION nleast
      2    (p_n        IN NUMBER,
      3       p_nums        IN VARCHAR2)
      4    RETURN           NUMBER
      5  AS
      6    v_nleast      NUMBER;
      7  BEGIN
      8    SELECT DISTINCT column_value
      9    INTO   v_nleast
    10    FROM   (SELECT column_value,
    11                  DENSE_RANK () OVER (ORDER BY column_value) AS num_rk
    12              FROM   (select *
    13                   from   table (CAST (str2tbl (p_nums) AS mytabletype)))
    14             WHERE   column_value IS NOT NULL)
    15    WHERE  num_rk = p_n;
    16    RETURN v_nleast;
    17  EXCEPTION
    18    WHEN OTHERS THEN RETURN NULL;
    19  END nleast;
    20  /
    Function created.
    scott@ORA92> SHOW ERRORS
    No errors.
    scott@ORA92> -- query:
    scott@ORA92> SELECT col1, col2, col3,
      2           LEAST (col1, col2, col3) AS the_least,
      3           nleast (1, col1 || ',' || col2 || ',' || col3) AS first_least,
      4           nleast (2, col1 || ',' || col2 || ',' || col3) AS second_least,
      5           nleast (3, col1 || ',' || col2 || ',' || col3) AS third_least,
      6           nleast (4, col1 || ',' || col2 || ',' || col3) AS fourth_least
      7  FROM   your_table
      8  /
          COL1       COL2       COL3  THE_LEAST FIRST_LEAST SECOND_LEAST THIRD_LEAST FOURTH_LEAST
             1          2          3          1           1            2           3
             4          6          5          4           4            5           6
             8          7          9          7           7            8           9
            11         12         10         10          10           11          12
            15         13         14         13          13           14          15
            18         17         16         16          16           17          18
    6 rows selected.

  • Array - return greatest value in the array

    I am trying to write a program that for the method 'greatest' it will return the greates value in the array between the elements beginning and end.
    Below is my code. No errors but I am not getting the desired results.
    My output:
    2
    4
    1
    5
    3
    6
    My code:
    public class Test {
         public void printArray(int x[]){
              for (int i=0; i < x.length; i++)
                   System.out.println(x[i] + "");
                  System.out.println("\n");
         public static int greatest(int x[], int beginning, int end){
              int i;
              int index = 0;
              int largest = 0;
              for(int z = 0; z < x.length; z++)
                 if(largest < x[z])
                    largest = x[z];
                    index = z;
              return index;
         public static void main(String[] args){
              Test program = new Test();
              int a[] = {2,4,1,5,3,6};
              int val = greatest(a,0,a.length-1);
              program.printArray(a);
    }Please, I just would like someone to point out where I need to focus. I do not want anyone to write this. Yes - its for college.
    Please and Thank you

    Kayaman - once again you have been helpful. Thank you.
    So I went to the paper and thought about the logic and rewrote what I had in the method greatest.
    * I am passing to the method, successfully calculating the greatest value, but not returning a varialble so the variable val is still not used. Or if I am returning a value I dont see it. *
    So, I need to return the value and then call the printArray method to print the outcome.
    What line needs to be addressed - remember anyone else reading this, please do not write it for me :-)
         public static int greatest(int x[], int beginning, int end){
               int max = x[0];
                 for (int i = 0; i < x.length; i++)
                  if (max < x)
         max = x[i];
         System.out.println("The greatest: " + max);
         return max;
    Please and Thank you :-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Finding greatest value of date in a table

    Hi experts,
    I have many dates in an internal table.How to find min and max dates of these.
    Is there any FM or i have to write logic.
    Please help.
    Krishan

    Hi Krishan,
    Adding to pavan ans....
    SORT itab BY date.
    DESCRIBE TABLE itab LINES l_lines. "Get total number of lines in itab.
    READ TABLE itab INTO wa INDEX 1 TRANSPORTING date. "Read first entry
    Here wa-date have Min date value.
    READ TABLE itab INTO wa INDEX l_lines TRANSPORTING date. "Read last entry
    Here wa-date Have Max date value.
    Thanks,
    Vinod.

  • Logging a string as the 2nd return value from a VI

    I have a VI that returns a Boolean pass/fail which maps into step.result.passfail.  I return another hex value from the same VI that only needs to be logged on the datasheet, but has no pass/fail status. It comes back via a telnet connection as a string. If I convert it to a number I can use the null type adapter and call it a numeric limit test with a comparison type of none and it will get logged on the data sheet without any pass fail consequences. It would be simpler just to pass back the string and have it logged. In fact this is a general case, there may be  many times I just want something returned from a VI to be logged on the data sheet without any checking. What testStand tool/object/gizmo could one use?
    Thanks,
    jvh

    Tool/object/gizmo to use is an Action Step
    Action Step
    The Action step calls code modules that do not perform tests but,
    instead, perform actions necessary for testing, such as initializing an
    instrument. By default, Action steps do not pass or fail. The step type does not
    modify the step status. Thus, the status for an Action step is Done or Error unless the
    code module specifically sets another status for the step or the step calls a
    subsequence that fails.
    You can use the TestStand - Evaluate.vi code module template to create a VI that includes a ReportText indicator.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • 2nd highest value

    Hi friends,
    I have table EMP with column (HIREDATE date);
    I can select the latest hired employee by using max(hiredate).
    How do I select the 2nd to the latest hired?
    Thanks a lot

    SQL> SELECT ename, hiredate FROM emp;
    ENAME      HIREDATE
    SMITH      80/12/17
    ALLEN      81/02/20
    WARD       81/02/22
    JONES      81/04/02
    MARTIN     81/09/28
    BLAKE      81/05/01
    CLARK      81/06/09
    SCOTT      87/04/19
    KING       81/11/17
    TURNER     81/09/08
    ADAMS      87/05/23
    ENAME      HIREDATE
    JAMES      81/12/03
    FORD       81/12/03
    MILLER     82/01/23
    14 wierszy zosta│o wybranych.
    SQL> SELECT MAX(hiredate) FROM emp;
    MAX(HIRE
    87/05/23
    SQL> SELECT hiredate, RANK() OVER (ORDER BY hiredate desc) FROM emp;
    HIREDATE RANK()OVER(ORDERBYHIREDATEDESC)
    87/05/23                               1
    87/04/19                               2
    82/01/23                               3
    81/12/03                               4
    81/12/03                               4
    81/11/17                               6
    81/09/28                               7
    81/09/08                               8
    81/06/09                               9
    81/05/01                              10
    81/04/02                              11
    HIREDATE RANK()OVER(ORDERBYHIREDATEDESC)
    81/02/22                              12
    81/02/20                              13
    80/12/17                              14
    14 wierszy zosta│o wybranych.
    SQL> SELECT hiredate FROM (SELECT hiredate, RANK() OVER (ORDER BY hiredate desc) AS r FROM emp) WHERE r = 2;
    HIREDATE
    87/04/19
    SQL>

  • 11g equivalent of Excel LARGE() function? (nth largest in set)

    I've been spinning my wheels on this and figured I'd give the forums a try.
    I need to find the 13th largest value over the previous 52 weeks. I can set the window size correctly using ROWS 52 PRECEDING AND CURRENT ROW ORDER BY WEEK, but then I need another sort for the nTH largest within that partition. NTH_VALUE is close but what I really need is NTH_LARGEST_VALUE. Excel has a LARGE() function to do this.
    Any thoughts for achieving this? See the example below:
    Column desired_output is what I'm looking to achieve. It is the 2nd largest value over the current row and the previous 2 rows (ordered by week). Assume no relationship between week and val. These values just used for illustration purposes.
    with tab as
        select to_date('4-jan-2012', 'dd-mon-yyyy')+(level-1)*7 week,
               to_number(to_char(to_date('4-jan-2012', 'dd-mon-yyyy')+(level-1)*7,'dd')) val,
               case when level in (1,2) then null
                    when level = 3 then 11
                    when level = 4 then 18
                    when level = 5 then 18
                    when level = 6 then 8
                    when level = 7 then 8
                    when level = 8 then 15
                    when level = 9 then 22
                    when level = 10 then 22
               end desired_result
          from dual connect by level <= 10
    select week, val, desired_result
      from tab
    order by week; 
    WEEK             VAL DESIRED_RESULT
    04-JAN-12          4
    11-JAN-12         11
    18-JAN-12         18             11
    25-JAN-12         25             18
    01-FEB-12          1             18
    08-FEB-12          8              8
    15-FEB-12         15              8
    22-FEB-12         22             15
    29-FEB-12         29             22
    07-MAR-12          7             22
    10 rows selected.Any advice would be appreciated. Thanks!

    Ok,
    Maybe this one :SQL> !cat q.sql
    with tab as
        select to_date('4-jan-2012', 'dd-mon-yyyy')+(level-1)*7 week,
               to_number(to_char(to_date('4-jan-2012', 'dd-mon-yyyy')+(level-1)*7,'dd')) val,
               case when level in (1,2) then null
                    when level = 3 then 11
                    when level = 4 then 18
                    when level = 5 then 18
                    when level = 6 then 8
                    when level = 7 then 8
                    when level = 8 then 15
                    when level = 9 then 22
                    when level = 10 then 22
               end desired_result
          from dual connect by level <= 10
    ------ end of sample data ------
    select fweek,val,desired_result, lval as calculated_result
    from (
         select fweek,val,desired_result,src,lval, row_number() over (partition by fweek order by lval desc nulls last) r
         from (
              select fweek,val,desired_result,lval,src
              from (
                   select to_char(week,'yyyymmdd') fweek, val, desired_result
                   , lag(val,0) over (order by week asc) lag00
                   , lag(val,1) over (order by week asc) lag01
                   , lag(val,2) over (order by week asc) lag02
                   from tab t
              unpivot include nulls (
                   lval for (src) in
                        (lag00 as 0
                        ,lag01 as 1
                        ,lag02 as 2
    where r=2
    SQL> @q
    FWEEK           VAL DESIRED_RESULT CALCULATED_RESULT
    20120104          4
    20120111         11                                4
    20120118         18             11                11
    20120125         25             18                18
    20120201          1             18                18
    20120208          8              8                 8
    20120215         15              8                 8
    20120222         22             15                15
    20120229         29             22                22
    20120307          7             22                22
    10 rows selected.I have a difference from your desired_result for 20120111 : To me the 2nd greatest value for the 2 previous week is 4. I don't get why you want a NULL instead.
    In order to have a bigger range (6 in the following example, but can be completed up to 52 weeks), the code should look like that :SQL> !cat q2.sql
    with tab as
        select to_date('4-jan-2012', 'dd-mon-yyyy')+(level-1)*7 week,
               to_number(to_char(to_date('4-jan-2012', 'dd-mon-yyyy')+(level-1)*7,'dd')) val,
               case when level in (1,2) then null
                    when level = 3 then 11
                    when level = 4 then 18
                    when level = 5 then 18
                    when level = 6 then 8
                    when level = 7 then 8
                    when level = 8 then 15
                    when level = 9 then 22
                    when level = 10 then 22
               end desired_result
          from dual connect by level <= 10
    ------ end of sample data ------
    select fweek,val,desired_result, lval as calculated_result
    from (
         select fweek,val,desired_result,src,lval, row_number() over (partition by fweek order by lval desc nulls last) r
         from (
              select fweek,val,desired_result,lval,src
              from (
                   select to_char(week,'yyyymmdd') fweek, val, desired_result
                   , lag(val,0) over (order by week asc) lag00
                   , lag(val,1) over (order by week asc) lag01
                   , lag(val,2) over (order by week asc) lag02
                   , lag(val,3) over (order by week asc) lag03
                   , lag(val,4) over (order by week asc) lag04
                   , lag(val,5) over (order by week asc) lag05
                   , lag(val,6) over (order by week asc) lag06
                   -- this should continue up to "lag(val,52) over (order by week asc) lag52"
                   from tab t
              unpivot include nulls (
                   lval for (src) in
                        (lag00 as 0
                        ,lag01 as 1
                        ,lag02 as 2
                        ,lag03 as 3
                        ,lag04 as 4
                        ,lag05 as 5
                        ,lag06 as 6
                        -- this should continue up to "lag52 as 52"
    where r=3
    SQL> @q2
    FWEEK           VAL DESIRED_RESULT CALCULATED_RESULT
    20120104          4
    20120111         11
    20120118         18             11                 4
    20120125         25             18                11
    20120201          1             18                11
    20120208          8              8                11
    20120215         15              8                15
    20120222         22             15                18
    20120229         29             22                22
    20120307          7             22                22
    10 rows selected.This is the 3rd value over the 6 previous weeks.
    <b><u>Nota :</u></b>
    For some unknown reason, I had to convert week to char because of <i>"ORA-01801: date format is too long for internal buffer"</i>
    I didn't try to change my NLS_DATE_FORMAT to see if that would help.

  • How to get the values of 2 dynamic comboboxes in one jsp to another jsp?

    I have 2 comboboxes and one submit button on my jsp page.I select a value in 1st combobox then the values in the second combobox populated from the database. next i select 2nd combobox and then submit the button.After submit the button call the next jsp page. In that page i want to display the values of two comboboxes. but my problem is , in that page only 2nd combobox value is displayed.1st combobox is displayed as null. plz tell me, how to get the values of two comboboxes at a time?
    Select.jsp:
    <%@ page language="java" import="java.sql.*" %>
    <%!
         Connection con = null;
         Statement  st  = null;
         ResultSet  rs  = null;
         String     sql = null;
         void addItems(javax.servlet.jsp.JspWriter out, String sql)
           try{     
              rs = st.executeQuery(sql);
              while( rs.next() )
                   out.println("<option>" + rs.getString(1) + "</option>");               
         }catch(Exception e)
                   System.out.println(e);
    %>
    <HTML>
    <HEAD>
    <TITLE>JSP WITH  MULTIPLE FORMS</TITLE>
    <script language="javascript">
              function checking()
                        form1.submit();
         </script>
    </HEAD>
         <body>
             <center>
             <b><font size="5" color="#333399">Staff ID:</font></b></center>
                     <FORM NAME="form1" METHOD="POST" ACTION="Select.jsp">
                         <p align=center>
                         Details of Staff :  
                       <SELECT 1 NAME="type" onchange="checking();">
                                    <option> Administrator </option>
                              <option> OfficeAssistent </option>
                              <option> Clerk </option>
                                  </SELECT 1>
                          </p>
    </FORM>
                      <FORM NAME="form2" METHOD="POST" action="welcome1.jsp">
                      <center>
                          <TABLE><TR><TD>Staff ID:</TD>
                                 <TD><SELECT 2 NAME="staff_id">
                    <%    
            String type = request.getParameter("type");
            try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection("jdbc:odbc:java","system","manager");
            catch (ClassNotFoundException ex) {
                   System.out.println(ex);
            catch (SQLException ex)
                System.out.println(ex);
         st  = con.createStatement();
         sql = "select staff_id from "+type+"";
         addItems(out, sql);
    %>
              </SELECT 2>
           </TD>
         </TR>
    </table></center>
    <h2> Details of <%= type + "s" %> </h2>
                         <center><input type=submit value=ok onclick="submit();"></center>
                  </FORM>
         </BODY>
    </HTML>
    welcome1.jsp
    <center><h1>WEL COME</h1></center>
    <%    
            String type = request.getParameter("type");
            String sid = request.getParameter("staff_id");
    %>
    <h2> Details of <%= type + "s" %> </h2>
    <h2> Details of <%= sid %> </h2>

    <SELECT 1 NAME="type" onchange="checking();">
                                    <option value = "0"> Administrator </option>
                              <option value = "1"> OfficeAssistent </option>
                              <option value = "2"> Clerk </option>
                                  </SELECT 1>

  • Values not changed in Report

    Hi,
    in BEx 7.0 Query out put is confusing.
    when I loaded Data in the Cube 2nd time.
    double Values are displayed in the Query  .
    When I loaded the Data, I deleted Data in PSA and cube too.
    <b>For Example : Plan activity Quantity 1st time value is 100 then</b>
    2nd time when i delted the PSA data & Cube data, then I loaded Cube
    <b>the value of Plan activity Quantity 2nd time value is 200 then</b>
    3rd time when I delted the PSA data & cube data then once again I loaded Cube
    <b>the value of Plan activity Quantiy 3rd time value is 300.</b>
    when I deleted the PSA data & Cube Data, I checked in the Query no data it is showing.
    That clearly Indicates not the problem of Cube.
    Problem with the Query.
    I am wondering how it is displayed like this.
    may be some property i need to concentrate.
    Then I saveAs this Query then The New Query is showing the Right Result
    But old is showing Wrong values like (double,triple)
    can anybody encounted this type of Problem in BEx 7.0
    I have 30 Queries , I don't won't to SaveAs All these Queries,
    some Queries has in WorkBook.
    that's why I am checking the Properties.
    Please Help me to find the solution
    I will assign Points.
    Thanks
    prasanna

    Hi,
    the exact explication why you have to do this, I don't know...
    but, out of my experience, I've noticed that If your cube is right and your query is right, but you get wrong results, you have to regenerate the definition of the query. Not by saving the query, but by 'generate' in RSRT. And 9 out of 10, you get the right result :o)
    I think that SAP remembers a version of the querydefinition, and uses that definition. If you do generate, you give SAP a new version...
    Greatz
    Joke

  • Use one value of multi value parameter in dataset query

    I have a parameter @Period that is populated with posting periods from our financial system (e.g. 201301, 201302, 201303, etc.).  It is set as a multi value parameter to allow users to choose multiple posting periods.  This parameter
    is used in my main dataset.  If the user chooses 201301 and 201302, I want to choose the greatest value chosen and use it in a where clause such that MyPostPeriod <= @Period.  Since @Period is a multivalue, the ><= won't work. 
    I read that SSRS just passes this as a comma separated value (201301,201302).  How do I find the greatest value in the list and how do I use that in my where clause?
    the user is selecting projects with activity during the posting period but then I want to grab all costs and invoices since the project was created.  They choose to see activity in 201301 and 201302 but I need to get all invoices and costs <= 201302.
    The only option I have been able to come up with is to have two parameters - one for start period and one for end period. Any better solutions?  I'm not using stored procedures.
    Milissa Hartwell

    Hi Milissa,
    Based on your description, you want to get the Maximum value from a multi-value parameter. We can insert the selected values into a temp table and get the Maximum values. Suppose we have main dataset (DataSet1) include Period field, and a parameter Period
    in the report. Please refer to the following steps:
    Create another dataset named DataSet2 using the query below.
    CREATE TABLE #Max (COL1 INT)
    INSERT INTO #Max Values(1)
    SELECT * FROM #Max
    Double click DataSet2, change the dataset using the expression below:
    ="CREATE TABLE #Max (COL1 INT)" &
    "INSERT INTO #Max VALUES (" & Join(Parameters! Period.Value,"),(") &")" &
    "SELECT TOP 1 * FROM #Max ORDER BY COL1 DESC"
    Create a parameter (Max) set the Data Type to “Integer”, and get the available values and default values from the DataSet2 COL1. Then, set the visibility to “Hidden”.
    Double click the DataSet1, click Filters in the left pane. Fill with following values:
    Expression: [Period]
    Operator: <=
    Value: [@Max]
    Please refer to the following screenshot:
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Mapping field to particularly a[2] element in an array of values.

    Hi Experts,
    The source structure is
    MT
    RootNode
            Parent(1..unbounded)
                     Contact(0..unbounded)
                             Phone(0..1)
                                   Subscriber(0..)
    I've to map a target node to Parent->Contact(1)->Phone->Subscriber node only and skipping all other occurences of Contact.
    How do we do it in PI?
    Regards,
    Vishal

    P836340 wrote:>
    > For Ex:
    > In my input file the following data come..
    > <?xml version="1.0" encoding="UTF-8"?>
    > <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
    >    <ns0:Message1>
    > <DT>
    >  <Contact >
    >                <Telephone >9857468<Property>
    >                <Description >EFGH<Description>
    > </Contact>
    >  <Contact >
    >                <Telephone >989897468<Property>
    >                <Description >EFGH<Description>
    > </Contact>
    > </Contact>
    >    </ns0:Message1>
    > </ns0:Messages>
    >
    > I want only the 2nd Telephone value to be used in mapping.
    Hi Vishal,
    You want ony the 2nd Telephone numer....
    Did you mean to say, If you are having 5 Telephone numbers you want to use only 2nd telephone number..
    Mention your requirement properly...
    Thanks.
    Edited by: Jyothi Anagani on Aug 21, 2009 11:58 AM

  • How to determine the "Last Value" in exception aggregation

    Hi gurus,
    I have a KeyFigure with an exception aggregation -Last value- by time.
    I report on a multiprovider ("containing" a infocube and a realtime infocube with BPS-InputLayout). I can correct separate Items with this BPS-Layout. So, at the end I have 2 values for one item.
    So, by these facts, my report shows the the last value for the specific KeyFigure, but I expected that both values (the value in the infocube and the correction via BPS)are sumed up.
    As this is due to the exception aggregation not the case, I could "overwrite" the normal value in the infocube with the BPS.
    But SAP determines the normal value in the Infocube as "Last Value", not the one in the correction cube, which is entered via BPS.
    How does SAP determine the "last value" as I can´t see any date...
    Thanks in advance!

    Thank you for your answer...
    I got the soltion by myself.
    I thought, Last Value means the last Value, depending on the time, but in my opinion the function last value should be called "Greatest Value".
    All figures with the same value for the reference characteristc are aggregated anyway.

  • How to get the sales value of the last month in the quarter

    Hi,
    We have a requirement to get the "Sales" value against a quarter. We have 2 tables "Time" and "Sales". We want to display the Sales value against each quarter.
    But this should happen as follows.
    Consider quarter Q1 it should display the value of 3rd month, Q2 should display value for 6th month and so on..
    If in any particular Quarter we dont have a value for last month then it should display the value for 2nd month, if 2nd month value is also not present then it should display 1st month sales value.
    We are using excel as the database.
    Please let us know if anybody has a resolution to this.
    Regards,
    Apoorv Chitre

    hi,make an other column which will be the flag for the last months you want to be displayed...
    so ,in reports,you pass it as hidden column(by filter only the ones which have the appropriate flag),and then voila...
    i hope i helped
    http://greekoraclebi.blogspot.com/
    ///////////////////////////////////////

  • How to Fetch the Row value in SBO Formatted search

    Hi Experts,
    I have created a Sales order, in which i  have 4 UDF Fields(A,B,C,D) in the following:
    Example values:
    A  B  C  D 
    2   2   4  4
    3   2   6  10
    C=A*B
    D=1st value of D + 2nd col value of C
    i have written query for C, but how to write the Formatted search Query for generation of D values. plz reply as soon as possible.

    Magesh,
    I quite understand what you are trying to do.   If you look at the example below I added a third row to show how you want the D to be a running total of column C. RIGHT !!
    A B C D
    2 2 4 4
    3 2 6 10
    <b>4 2 8 18</b>
    Honestly, it is not going to be simple as you do not have a way in SBO to access a particular column from a row.  When you say $[$38.U_C] it refers to the context row OR the row which has the highlight OR the row which has the curson on it.
    It is not possible to say $[$38.U_C from row 2]  JUST  NOT POSSIBLE ...
    You have to write a tricky code by using a temp table referencing the value of column C.  Also you have to keep track if Rows gets deleted and a new row added. 
    I will test a sample code and will come back.
    Suda

Maybe you are looking for

  • Payment report error

    This causes us a problem every time we make a payment run. The supplier payment report says it cannot generate the payment as there are no bank details set up - however when I attempt to put in the details i get the message; "this entry already exist

  • PDF's in Mail and Preview not displaying correctly

    Ever since upgrading to Yosemite PDF's are not displaying correctly. Every time i generate a PDF of a sales quote it seems to lose a lot of information. But the strange thing is..... Preview and Mail both show PDF with missing text. When I open using

  • Non-printing Text?

    I have a form I need to create that includes information I do not want to have printed on paper. In MS Word I can just set the the selected text to "hidden" and it can be seen on the computer screen but wont print. Is there a way to do this in Pages?

  • Adobe Life cycle designer ES2 Activex control

    I have Adobe Lifecycle designer ES2 tool installed in my PC. I need to get the Activex control for adobe Life cycle tool so that i can use it to programatically create and edit the PDF file. can any one help me in finding the name of the activex cont

  • Install oracle db 11g r2 on Windows 7 Error

    Hi, i install oracle db 11g r2 on windows 7 ultmate and founded error : file not found orandce11.dll.dbl and file not found orancds11r.dll.dbl how to solution ? thanks, Khun