Problem in summation on a column with possible null values

Hi,
I want to do summation on a column.
If I use <?sum(amount)?>, if there is any null value,its giving NaN as output.
From the forum I got the below syntax
<?sum(AMOUNT[number(.)!='NaN'])?>
but it is also not giving me the expected result. Its always displays 0.
I want some thing like sum(NVL(amount,0)). Could some body please help me out?
Thanks in Advance,
Thiru

If the column has many, many null values, and you want to use the index to identify the rows with non-null values, this is a good thing, as a B*Tree index will not index the nulls at all, so, even though your table may be very large, with many millions of rows, this index will be small and efficient, cause it will only contain index entries for those rows where the column is not null.
Hope that helps,
-Mark

Similar Messages

  • How to update person or group column with peopleeditor control values

    Hi,
    I have created custom aspx page and added "PeopleEditor" control(can select multiple users)  in that page. Now I am trying to update person or group column with peopleeditor control values.I am not getting any error if I select single user
    in PeopleEditor control but getting error if I select more than one user.
    UpdateItem(listItem, "ListColumnName",
    listItem.ParentList.ParentWeb.EnsureUser(peopleeditorId.CommaSeparatedAccounts));
    Can anybody help me out to resolve the issue?
    Thank you in advance!!!
    AA.

    First get all the users/groups from the PeapleEditor by using PeapleEditor.ResolvedEntities
    foreach (PickerEntity pickerEntity in peopleEditor.ResolvedEntities)
    SPPrincipalType principalType = (SPPrincipalType)Enum.Parse(typeof(SPPrincipalType), pickerEntity.EntityData["PrincipalType"].ToString());
    if (principalType == SPPrincipalType.User || principalType == SPPrincipalType.SecurityGroup)
    string loginName = pickerEntity.Key;
    //your code here
    else if (principalType == SPPrincipalType.SharePointGroup)
    string groupName = pickerEntity.Key;
    //your code here
    Add all the users/groups in an instance of SPFieldUserValueCollection
    and then update your list item.
    SPFieldUserValueCollection users = new SPFieldUserValueCollection();
    users.Add(new SPFieldUserValue(web,user.ID,user.Name));
    item["YourUserColumn"] = users;
    item.Update();

  • Show row/column with empty dimension values.

    I have 2 columns where 1 column is dimension and 1 column is measure.  I need to hide the row when the dimension is empty.
    What I did is at the block I UN-TICK  "Show row/column with empty dimension values".  But it didnt works.
    Thanks.

    click on the block and add a filter with condition dimension isnotnull. this will eliminate the dimension rows with empty values.
    Thanks,
    karthik

  • Column with header data value

    Hi All.
    I have a control file which i need to add a column with header data value.
    example
    data file:
    123456;201303
    santiago;producto1;100
    santiago;producto2;200
    valparais;producto1;400
    valparais;producto3;900
    The control file skip the first column and load the three columns on the table, but, now i need to add other column with 201303 value constant of the first record and load it on the table.
    Then
    select * from table:
    santiago producto1 100 201303
    santiago producto2 200 201303
    valparais producto1 400 201303
    valparais producto3 900 201303
    How i do this in the control file?
    Regards!

    SCOTT@orcl_11gR2> host type test.dat
    123456;201303
    santiago;producto1;100
    santiago;producto2;200
    valparais;producto1;400
    valparais;producto3;900
    SCOTT@orcl_11gR2> host type test1.ctl
    options (load=1)
    load data
    infile test.dat
    replace
    into table onecol_onerow
    fields terminated by ';'
    trailing nullcols
    (filler1 filler, newcol)
    SCOTT@orcl_11gR2> host type test2.ctl
    options (skip=1)
    load data
    infile test.dat
    append
    into table test_tab
    fields terminated by ';'
    trailing nullcols
    (col1, col2, col3,
    newcol expression "(select newcol from onecol_onerow)")
    SCOTT@orcl_11gR2> create table onecol_onerow
      2    (newcol number)
      3  /
    Table created.
    SCOTT@orcl_11gR2> create table test_tab
      2    (col1   varchar2(15),
      3     col2   varchar2(15),
      4     col3   number,
      5     newcol number)
      6  /
    Table created.
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test1.ctl log=test1.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Mon May 6 10:46:44 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 1
    SCOTT@orcl_11gR2> select * from onecol_onerow
      2  /
        NEWCOL
        201303
    1 row selected.
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test2.ctl log=test2.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Mon May 6 10:46:45 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 4
    SCOTT@orcl_11gR2> select * from test_tab
      2  /
    COL1            COL2                  COL3     NEWCOL
    santiago        producto1              100     201303
    santiago        producto2              200     201303
    valparais       producto1              400     201303
    valparais       producto3              900     201303
    4 rows selected.

  • Query on column with comma separated values

    I have a proposed table with unnormalized data like the following:
    ID COLA COLB REFLIST
    21 xxx  zzz  24,25,78,412
    22 xxx  xxx  21
    24 yyy  xxx  912,22
    25 zzz  fff  433,555,22
    .. ...  ...  ...There are 200 million rows. There is maximum of about 10 IDs in the REFLIST, though typically two or three. How could I efficiently query this data on the REFLIST column? e.g. something like:
    SELECT id FROM mytable WHERE :myval in reflistLogically there is a many to many relationship between rows in this table. The REFLIST column contains pointers to ID values elsewhere in the table. The data could be normalized so that the relationship keys are in a separate table (in fact this is the current solution that we want to change).
    ID  REF
    21  24
    21  25
    21  78
    21  412
    22  21
    24  912
    ... ...The comma separated list seems instinctively like a bad idea, however there are various reasons for proposing it. The main reason is because the source for this data has it structured like the REFLIST example. It is an OLTP-like system rather than a data warehouse. The source code (and edit performance) would benefit greatly from not having to maintain the relationship table as the data changes.
    Going back to querying the REFLIST column, the problem seems to be building an approriate index for the data. The ideas proposed so far are:
    <li>Make a materialized view that presents the relationships as normalized (e.g. as in the example with ID, REF columns above), then index the plain column - the various methods of writing the view SQL have been widely posted.
    <li>Use a Oracle Text Index (not something I have ever had call to use before).
    Any other ideas? Its Oracle 10.2, though 11g could be possible.
    Thanks
    Jim

    Something like this ?
    This is test demo on my 11.2.0.1 Windows XP
    SQL> create table test (id number,reflist varchar2(30));
    Table created.
    SQL> insert into test values (21,'24,25,78,412');
    1 row created.
    SQL> insert into test values (22,'21');
    1 row created.
    SQL> insert into test values (24,'912,22');
    1 row created.
    SQL> insert into test values (25,'433,555,22');
    1 row created.
    SQL> select * from test
      2  where
      3  ',' || reflist || ',' like '%,22,%';
            ID REFLIST
            24 912,22
            25 433,555,22
    SQL>Source:http://stackoverflow.com/questions/7212282/is-it-possible-to-query-a-comma-separated-column-for-a-specific-value
    Regards
    Girish Sharma
    Edited by: Girish Sharma on Jul 12, 2012 2:31 PM

  • Compare column to another column with a specific value?

    What i need to do is compare a column that holds the SiteNames of holidays to another column with the DifficultyDescription of holidays.
    I want to show that sites that are not included in boldANY*bold* holiday with an “easy” or “moderate” rating.
    Some of my SiteNames have holidays with different difficulty ratings....
    e.g Yellowstone National Park(SiteName) - H2 - Moderate(DifficultyDescrip)
    Yellowstone National Park(SiteName - H3 - Strenuous(DifficultyDescrip)
    In this example i would want Yellowstone not to be in the results of my query as one of its results is 'moderate'.
    I want to show holidays that are not in boldANY*bold* holiday with 'easy' or 'moderate'
    Here is my attempt so far...
    select it220_holdet.holcode.holcode as holcode
             it220_holdet.diffdetails.diffdescrip as diffdescrip
             it220_sitedetails.sitename as sitename
    from it220_holidaydetails it220_holidaydetails,
    etc....
    where it220_sitedetails.sitename != it220_diffdetails.diffdescrip = 'Easy' <<<< where the sitename is not equal to a difficulty description of 'Easy'
    and     it220_sitedetails.sitename != it220_diffdetails.diffdescrip = 'Moderate' <<<< where the sitename is not equal to a difficulty description of 'Moderate'
    Is the logic of this correct? The error message i am getting is SQL command not properly ended.
    Is this more of a syntax problem than logic. Any help would be great.
    Thanks in advance!
    Edited by: Jay on 19-Nov-2010 02:47
    Edited by: Jay on 19-Nov-2010 02:47

    Hi,
    Ok,
    Problem is in this part of query
    where   "IT220_HOLIDAYDETAILS"."DIFFRATING"="IT220_DIFFDETAILS"."DIFFCODE"
    and      "IT220_HOLIDAYDETAILS"."HOLCODE"="IT220_LOOKUP_SITEHOLIDAY"."HOLCODE"
    and      "IT220_LOOKUP_SITEHOLIDAY"."SITECODE"="IT220_SITEDETAILS"."SITECODE"
    and "IT220_SITEDETAILS"."SITENAME" = "IT220_DIFFDETAILS"."DIFFDESCRIP"
    and "IT220_SITEDETAILS"."SITENAME" =  "IT220_DIFFDETAILS"."DIFFDESCRIP"
    Check are you joining correct columns.
    And remove possibility that tables values are in different cases
    SELECT "IT220_HOLIDAYDETAILS"."HOLCODE" AS "HOLCODE",
      "IT220_HOLIDAYDETAILS"."COUNTRYVIS"   AS "COUNTRYVIS",
      "IT220_DIFFDETAILS"."DIFFDESCRIP"     AS "DIFFDESCRIP",
      "IT220_SITEDETAILS"."SITENAME"        AS "SITENAME"
    FROM "IT220_SITEDETAILS" "IT220_SITEDETAILS",
      "IT220_LOOKUP_SITEHOLIDAY" "IT220_LOOKUP_SITEHOLIDAY",
      "IT220_DIFFDETAILS" "IT220_DIFFDETAILS",
      "IT220_HOLIDAYDETAILS" "IT220_HOLIDAYDETAILS"
    WHERE UPPER("IT220_HOLIDAYDETAILS"."DIFFRATING")  = UPPER("IT220_DIFFDETAILS"."DIFFCODE")
    AND UPPER("IT220_HOLIDAYDETAILS"."HOLCODE")       = UPPER("IT220_LOOKUP_SITEHOLIDAY"."HOLCODE")
    AND UPPER("IT220_LOOKUP_SITEHOLIDAY"."SITECODE")  = UPPER("IT220_SITEDETAILS"."SITECODE")
    AND UPPER("IT220_SITEDETAILS"."SITENAME")         = UPPER("IT220_DIFFDETAILS"."DIFFDESCRIP")
    AND UPPER("IT220_DIFFDETAILS"."DIFFDESCRIP") NOT IN('EASY','MODERATE')Regards,
    Jari

  • Grand Total with few NULL values in column.

    Hi All,
    In my requirement, I have few null values in the column and I have to show those null values as it is( can't use IfNull function).
    Can I able to grand total in such scenerio..?
    I am using OBIEE 11.1.1.3
    Thanks,
    Archie

    HI Archie,
    Are you using the "Grand Total" option that comes with the view?.I don't think there will be any issue , it will ignore the null values while calculating the total.
    Rgds,
    Dpka

  • Finding Columns with only NULL as values

    I have a list of tables around 30 in number. Among them i need to generate a report with Table Name and Column Names, for which all values are NULL.
    In other words, i need to find all the columns for which all the values are NULL.
    I thought of dealing it with cursors, and comparing the total count with null count in each column. But i need to loop "Number of columns" times. Is there any better way to do this?

    I think your way is a good solution. It has the advantage that you can check several columns in one select.
    select count(*), count(col1), count(col2) ... from mytabAnother approach could be to check statistical information about your table data.
    However this will not give you always the correct data.
    It depends on the time of the last statistic collection, the sample size and on the detail level.
    Here is a sample statement to play with:
    select owner, table_name, column_name, num_distinct, num_nulls, num_buckets, sample_size, low_value, high_value
    from all_tab_columns
    where owner not in ('SYS','SYSTEM')
    and nullable = 'Y' -- null values allowed
    and num_distinct = 0 -- only nulls found
    --and density = 0
    ;Note that this select would not return tables for which no statistics had been calculated. Num_distinct is NULL in such a case.
    Edited by: Sven W. on Feb 11, 2010 2:50 PM

  • N:1 mapping problem with incoming NULL value

    Dear experts,
    i have a problem mapping an incoming Idoc to XML file. Here's the situation:
    1) Structure of inbound Idoc
        ZTST00
        ZTST01 Structure: FIELDNAME, FIELDVALUE. Values: FIELDNAME = "Z1", FIELDVALUE = "4";
        ZTST01 Structure: FIELDNAME, FIELDVALUE. Values: FIELDNAME = "Z2", FIELDVALUE = null;
        ZTST01 Structure: FIELDNAME, FIELDVALUE, Values: FIELDNAME = "ZABC", FIELDVALUE = "5";
        ZTST01 Structure: FIELDNAME, FIELDVALUE. Values: FIELDNAME = "Z4", FIELDVALUE = "6";
        ZTST02
    2) Resulting XML:
        LINEHEADER (1 line)
        LINEDETAIL (1 line, Structure: VALUE)
        LINEFOOTER (1 line)
    3) I need to map ZTST01-FIELDVALUE to LINEDETAIL-VALUE, but only if the FIELDNAME equals "ZABC".
    In my message mapping, i put an IF FIELDNAME = 'ZABC' THEN FIELDVALUE->VALUE, on context ZTST00. But because of the null value in line 2 of the Idoc, the value that is returned to the XML is "6", as the null value is disregarded and not in the queue of FIELDVALUE.
    How can I put the correct value ("5") to LINEDETAIL-VALUE?
    Regards
    William

    Hi William,
    Simply go back to the default context ZTST01 (for both: FIELDNAME and FIELDVALUE fields) and it should be fine.
    Hope this helps,
    Greg

  • Is their a difference between primary key and unique key with not null valu

    What is the difference in having a column as primary key and having unique key with not null for the column.
    vinodh

    SBH wrote:
    For quick review, below is the link
    http://www.dba-oracle.com/data_warehouse/clustered_index.htm
    You appear to have stumbled on a site that is a mine of disinformation about Oracle.
    >
    It would be helpful, if you explain it too..thnx !!
    The site is wrong and makes up its own terminology as it goes along.
    If the value for clustering factor approaches the number of blocks in the base table, then the index is said to be clustered. http://www.oracle.com/pls/db112/search?remark=quick_search&word=clustered+index
    There is no create clustered index in Oracle.
    - Clustering factor affects the efficiency of an index.
    - There can be clustered tables that you can create indexes on.
    - An Index Organized table is a similar concept to the Microsoft SQL Server clustered index, but it isn't the same thing at all.

  • ODI - Issue with handling null value

    Hi,
    I have a flat file as below. When i am trying to load the data file into Essbase through ODI, i am not able to load. If i given the Null value as 0, i'm able to load the file into Essbase. If we pass 0 in place of null value, blocks will be created in Essbase and it might cause the performance issue.
    Account,Product,Customer,Version,Year,BU,Data
    A1,P1,C1,V1,2010,BU1,7677
    A2,P2,C2,V2,2010,BU2,0908
    A3,P3,C3,V1,2010,BU3,
    Can any one help if there is any way to handle the null values to load the data into Essbase?
    Your help is more important to us as it is one of the critical one we are facing.
    Thanks
    V D Reddy

    Hi
    I am not using any query.
    Data column is empty (no data) for few records in my flat file. After the data load is done to Hyperion Essbase, in the excel retrieve should show me as #Missing. But ODI is defaultly loading it as 0 into Essbase.
    Is there any way to load it as #Missing?
    Thanks
    V D Reddy

  • How to replace a "notfound" output with a null value?

    hi,
    I'm just getting a output of "Rows Notfound" for a script..
    instead of this , i just need to show the output with a record as null value or some value..
    do we have any option to use this in oracle..

    Apart from capturing with an exception in PL/SQL code, if you're wanting something in a script as pure SQL, you'd have to generate an additional row and only select that where no data is found e.g...
    SQL> ed
    Wrote file afiedt.buf
      1  select ename from emp where ename = 'FRED'
      2  union all
      3* select 'No Data' from dual where not exists (select * from emp where ename = 'FRED')
    SQL> /
    ENAME
    No Data
    SQL>Of course this does effectively double-up on the queries being executed, so if you're dealing with a heavily complex query, it may be best just just have the regular exception come out, but then this will also depend on your actual requirements and why you want to do this in the first place.

  • How to select only rows which column has a null value?

    Hi,
    I adds rows to my table with data field set to null;
    "INSERT INTO administrator.subzamowienia (subzamowienia.id_zamowienia,subzamowienia.id_transakcji,subzamowienia.nazwa_o,subzamowienia.nazwa_produktu,subzamowienia.ilosc,subzamowienia.nip_d,subzamowienia.data_realizacji) VALUES (administrator.id_zamowienia.curval,'0','PRAGA','Witaminy','2','43224','0');"
    Then i would like to update this field after a time with new date.
    To do this i need to know which rows has still data field set to null, i try sth like this but it doesn't work
    "SQL> select * from administrator.subzamowienia where subzamowienia.data_realizacji='null';
    select * from administrator.subzamowienia where subzamowienia.data_realizacji='null'
    B&#321;&#260;D w linii 1:
    ORA-01841: (pe&#322;ny) rok musi by&#263; pomi&#281;dzy -4713 i +9999 i nie mo&#380;e by&#263; 0
    or
    "SQL> select * from administrator.subzamowienia where subzamowienia.data_realizacji='0';
    select * from administrator.subzamowienia where subzamowienia.data_realizacji='0'
    B&#321;&#260;D w linii 1:
    ORA-01840: warto&#347;&#263; wej&#347;ciowa jest za krótka dla formatu daty
    how to choose this rows?

    Hi,
    VALUES (administrator.id_zamowienia.curval,'0','PRAGA','Witaminy','2','43224','0');I don't see null value...
    select * from administrator.subzamowienia where subzamowienia.data_realizacji='null'Should be :
    select * from administrator.subzamowienia where subzamowienia.data_realizacji is nullNicolas.

  • Problem when passing string array in sessions showing null value

    i am trying to pass a string array but it is showing me the null value
    i think the the problem is seem to be in session.settAttribute("subject['"+i+"']",subject) in 2.login_action.jsp
    or in String sub1=(String) session.getAttribute("subject[0]"); in 3.user_home.jsp
    i have following three pages
    1.login.html
    2.login_action.jsp
    3.user_home.html
    1.login.html
    <html>
    <body>
    <form method="post" action="login_action.jsp">
    Username<input type="text" name="username"></input>
    <br>
    Password<input type="password" name="password"></input>
    <input type="submit" value="login"></input>
    </form>
    </body>
    </html>
    2.login_action.jsp
    <%@ page contentType="text/html"%>
    <%@ page import="java.sql.*" %>
    <%!
    String user,pwd;
    String subject[]=new String[10];
    int i,totalsubject;
    %>
    <%
    try
    user=request.getParameter("username");
    pwd=request.getParameter("password");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:ods","scott","tiger");
    PreparedStatement ps = con.prepareStatement("select password from users where username='"+user+"'");
    ResultSet rs = ps.executeQuery();
    if(rs.next())
    if(rs.getString("password").equals(pwd))
    session.setAttribute("username",user);
    PreparedStatement ps2 = con.prepareStatement("select subject_id from allot_teachers where staff_id='"+user+"'");
                        ResultSet rs2 = ps2.executeQuery();          
                             while(rs2.next())
                             i=0;
                             subject[i]=rs2.getString(1);
    // if i display here the subjects in out.println(subject[i]) it is working fine
    // but in next redirected page it is showing null
                             session.setAttribute("subject['"+i+"']",subject[i]);
                             //out.println(subject[i]);
                             i++;
    response.sendRedirect("user_home.jsp");
    else
    out.println("error invalid username or password");
    else
    out.println("error invalid username or password");
    con.close();
    catch(Exception e)
    out.println(e);
    %>
    3. user_home.jsp
    <%@ page contentType="text/html"%>
    <%@ page import="java.sql.*" %>
    <html>
    <%
    String user,pwd,cat,cat1;
    String username=(String) session.getAttribute("username");
    if(username==null)
    response.sendRedirect("login.html");
    //just tried for first two subjects
    String sub1=(String) session.getAttribute("subject[0]");
    String sub2=(String) session.getAttribute("subject[1]");
    //here it is printing null
    out.println(sub1);
    //here it is printing null
    out.println(sub2);
    %>
    <form method="post" action="logout.jsp">
    <input type="submit" value="Logout"></input>
    </form>
    </html>
    Cheers & Regards
    sweety

    The name in getAttributre doesnt match the name in setAttribute.
    Note "subject[0]" is a string containing 10 chars, "subject" is a string containing 7 chars.
    Here is your code:
    session.setAttribute("subject",subject);
    String sub1=(String) session.getAttribute("subject[0]");

  • Security Attributes with Multiple/NULL values

    I have a couple of situations where I can't seem to get the authorization component working as I need it to work for a database source.
    1) In the first case, I have two attributes set for "grant security attributes" in the data source, one of which has a single attribute value, and the other which has multiple values, e.g.
    I want to set "grant security attributes" to something like "client_id role_id" where for my dataset, client_id will always be a single numeric value, but I might have multiple role_ids that can view this record. How do I specify in my data source query those multiple attribute values? I tried separating them with spaces, e.g.
    SELECT ...
    'A B' role_id
    FROM
    where "A" and "B" represent unique values (looking to match A OR B). I also tried delimiting them with commas, but neither spaces nor commas seems to work consistently.
    On the authorization end, using oracle.search.plugin.security.auth.db.DBAuthManager as the authorization plug-in, I have the authorization query set as
    SELECT client_id, security_lvl as role_id from test_user_id where user_id = ?
    Each user may have more than one role, so in the above query, security_lvl could be something like "B C"; I'm assuming from the documentation that the delimiter for attribute values in this case should be a space.
    The crawler logs make it appear that everything is getting indexed, so I suspect the issue is on the authorization front.
    2) In the second case, one of my security attributes for the data source may be NULL, meaning that there's no particular authorization restriction on a particular record, so to use the same example as in #1,
    role_id might be NULL for some records, in which case, I want those records returned in the search if the client_id matches, but I can't get the records with the NULL role_id to be returned at all. Again, the crawler logs indicate that everything is being indexed, and I'm not sure if there's a log where I can further troubleshooting authorization issues.
    Any guidance would be appreciated.
    Thanks

    1) The security attributes are OR'd together so if the user has any ONE of the attributes (either client ID or role ID), the document can be seen by the user. What I would try is to create a view to call rather than directly against the table. The view can then leverage a PL/SQL function and encapsulate the logic behind the security tokens to return.
    So the view would look like this...
    CREATE OR REPLACE VIEW USER_SECURITY_V AS
    SELECT
    USER_T.ID,
    MY_SECURITY_FUNCTION(USER_T.ID) AS AUTH_ID
    FROM
    USER_T
    The PL/SQL function would look something like this...
    CREATE OR REPLACE FUNCTION MY_SECURITY_FUNCTION(USER_ID NUMBER) RETURN VARCHAR2 IS
    -- Do whatever you need to do to build a single space-deliminted list of tokens for both Client and Role ID "CLIENTID4 ROLEID5 ROLEID9" then return
    END;
    The data source authorization query then would look like this...
    SELECT AUTH_ID FROM USER_SECURITY_V A WHERE A.ID = ?
    Using a PL/SQL Function to control the tokens gives you the flexibility of modifying security without having to touch the data source directly
    2) I don't quite follow. If any ONE of the tokens match, the document is returned. If the role ID is null, you might try stamping each document a "master" security token indicating it's open to everyone such as "ALL". Then in the PL/SQL Function, return "ALL" in front of the actual values.
    The crawler logs will only tell you what is indexed at crawl time, not how searching is actually working. Try checking the server logs. These should be under something like oracle/ses/seshome/search/base_domain/servers/AdminServer/logs
    Hope this helps!

Maybe you are looking for