Count the all null values in the given table

Suppose a table has n number of rows and columns .
can any one tell the query to count the number of null values present in the table.
For example :
select * from tname:
A      B
cc    jhghf
hff      -
-       kjh
tys     -
-        gyrfg
jjgg      -
jfgh      -
-        uytg
10 rows selected..
now to count the null vales in the table we can use --->   select count(1)-count(a)+count(2)-count(b) as ncount  from tname;
                                                                                  o/p:
                                                                                          ncount
                                                                                           11
now my questions is we have n number of columns now pls tel tell me how to count the nulls present in table..?
Thanks in Advance.

Object[][] o;
int tot = 0;
for(int x = 0 ; x < o.length ; x++)
   tot += o[x].length;
}If it's not a jagged array, however, this would be easier:
int tot = o.length * o[0].length;

Similar Messages

  • How to get the last column info of the given table

    Hi All,
    I want to get the last column information like :
    column name, datatype of the last column in the given
    table use PL statement. Please help.
    Thanks,
    JP

    SCOTT@orcl SQL> desc emp
    Name                                                  Null?    Type
    EMPNO                                                 NOT NULL NUMBER(4)
    ENAME                                                          VARCHAR2(10)
    JOB                                                            VARCHAR2(9)
    MGR                                                            NUMBER(4)
    HIREDATE                                                       DATE
    SAL                                                            NUMBER(7,2)
    COMM                                                           NUMBER(7,2)
    DEPTNO                                                         NUMBER(2)
    SCOTT@orcl SQL> select column_name, data_type from user_tab_columns
      2  where table_name = 'EMP'
      3  and column_id = (select max(column_id) from user_tab_columns
      4  where table_name = 'EMP');
    COLUMN_NAME                    DATA_TYPE
    DEPTNO                         NUMBER
    SCOTT@orcl SQL>                                                                      

  • Distinct Count of Non-null Values

    I have a table that has one column for providerID and then a providerID in each of several columns if the provider is under a particular type of contract. 
    I need a distict count of each provider under each type of contract for every county in the US.
    distinct count is almost always one more than the actual distict count because most counties have at least one provider that does not have a particular contract and the distict count counts the null value as a distict value.
    I know I can alter the fields to have a zero for nulls, ask for a minimum count and then subtract 1 from the distict count if the minimum is zero, but I hope there is an easier way to figure distict counts of non-null values.
    any suggestions?
    Thanks,
    Jennifer

    Hello,
    *I need a distict count of each provider under each type of contract for every county in the US*
    To the above requiremetn,
    I will suggest the following approach.
    Use group expert formula  for country, contract and provider.
    Now you will have the hierarchy to which level you want to apply distinct count. You can do it as suggested by ken hamady.
    Regards
    Usama

  • How to find the Datasources for the given table names ?

    Hi All,
    I have an urgent requirement where I ned to find the names of BW Datasources, created for the given table names.
    Both the tables and Datasources are in BW system only. I can see the table in SE11 but I am unable to find its associated Datasources in the 'Where Used List'.
    Is there any method ?
    Will assign points to satisfactory answers.
    Regards,
    Srinivas

    Hi,
    Check this thread on how to find the DS.
    I have the field name, please help me find the data source.
    Once you identify your DS you find which all Data targets are fed by trying to see the " Show data flow" in RSA1 for this data source.
    Hope this helps.
    Thanks,
    JituK
    Edited by: Jitu Krishna on Apr 30, 2008 11:52 AM

  • Update table all null values to 0 single query

    hi dear ;
    How Can I do , update table all null values to 0 using single query or procedure

    declare @tableName nvarchar(100)
    declare @querys varchar(max)
    set @querys = ''
    set @tableName = 'YOUR TABLE NAME HERE'
    select @querys = @querys + 'update ' + @tableName + ' set ' +
    QUOTENAME(t.[name]) + '=0 where ' + QUOTENAME(t.[name]) + ' is null;'
    from (SELECT [name] FROM syscolumns
    WHERE id = (SELECT id
    FROM sysobjects
    WHERE type = 'U'
    AND [NAME] = @tableName))t
    select @querys
    execute sp_executesql @sqlQuery
    Reference:
    http://stackoverflow.com/questions/6130133/sql-server-update-all-null-field-as-0
    -Vaibhav Chaudhari
    this code is return update TABLE set [FIELD]=isnull([FIELD],''),update TABLE set [FIELD2]=isnull([FIELD2],'')
    I want to use UPDATE TABLE SET FIELD1=ISNULL(FIELD1,0),FIELD2=ISNULL(FIELD2,0),FIELD3=ISNULL(FIELD3,0)  So CUT another update and set statement .

  • Knowing the primary key columns of the given table

    Hi,
    How can I get the primary key columns of the given table?
    Regards,
    Sachin R.K.

    You can find the constraint_name from all_constraints/user_constraints for constraint_type = 'P' (which is the primary key constraint).
    And then see which columns are in for the constriant_name
    in all_cons_columns/user_cons_columns view.
    Below is the example
    select acc.column_name from
    all_cons_columns acc, all_constraints ac
    where acc.constraint_name = ac.constraint_name
    and acc.table_name = 'DEPT' AND acc.owner = 'SCOTT'
    and ac.constraint_type = 'P'
    Hope this helps
    Srinivasa Medam

  • Count of all nulls in a Table

    Hi all,
    Is there a way to find out the count of all the null fields in a table?
    One way is obvious:-
    SQL> select * from test6152;
             A B   DD
             1 one <null>
             2 two <null>
             3 tri <null>
             3 dri <null>
             1 <nu 01-JAN-08
               ll>
             1 ch  01-JAN-08
    6 rows selected.
    SQL> select a + b + c from
      2  (
      3  select sum(case when a is null then 1 else 0 end) a ,
      4  sum(case when b is null then 1 else 0 end) b ,
      5  sum(case when dd is null then 1 else 0 end) c
      6  from
      7  test6152
      8  )
      9  /
         A+B+C
             5
    .Is there any other viable way to find the count of null fields in a table with say 80 fields.??
    Thanks in advance.

    You solution is already a good one.
    I personally would prefer "decode" instead of "case" in the case. but that's only a matter of style.
    DECODE(a,null,1,0)Another possibility is first to string all rows together and count the number of nulls in that row. Then add everything up.
    E.g. (not tested!)
    SELECT SUM(
                    LENGTH(
                                 decode(a,null,'x','')
                              || decode(b,null,'x','')
                              || decode(c,null,'x','')
                              || decode(d,null,'x','')
    FROM test6152

  • Join conditions for the given tables

    Hi,
    I would like to join the below tables
    FA_INVOICE_DETAILS_V FID
    ,AP_INVOICE_PAYMENT_HISTORY_V AIP
    ,PO_DISTRIBUTIONS_all PD
    ,AP_BATCHES_ALL AB
    ,PO_HEADERS_ALL POH
    ,PO_LINES_ALL POL
    ,FA_ADDITIONS_V FAA
    can anyone give me the conditions to join the above tables. Its an urgent please suggest me
    Thanks in advance

    Only you can know how to join those tables. We don't know your business, your data, or your requirements.
    If you would like us to help you, you need to provide the definitions of all the tables and which columns match between these tables. Then you have to tell us if you want inner joins, outer joins, theta joins, etc.
    Please see the following link:
    Urgency in online postings

  • Clarification needed on the behaviour of count with null values

    Hi friends,
    I am confused about the result given by the count aggregate function when dealing with null. Please can anybody clarify about that to me. Here is what i tried
    CREATE TABLE Demo ( a int);
    INSERT INTO Demo VALUES
    (1),
    (2),
    (NULL),
    (NULL);
    SELECT COUNT(COALESCE(a,0)) FROM Demo WHERE a IS NULL; -- Returns 2
    SELECT COUNT(ISNULL(a,0)) FROM Demo WHERE a IS NULL; -- Returns 2
    SELECT COUNT(*) FROM Demo WHERE a IS NULL; -- Returns 2
    SELECT COUNT(a) FROM Demo WHERE a IS NULL; -- Returns 0
    Please can anybody explain me why the result is same for the first three select statements and why not for the last select statement. And what does COUNT(*) actually mean?
    With Regards
    Abhilash D K

    There is a difference to the logic when using a column name versus "*" - which is explained in the documentation (and reading it is the first thing you should do when you do not understand a particularly query/syntax).  When you supply a column
    (or expression) to the count function, only the non-null values are counted.  Isnull and coalesce will obviously replace a NULL values, therefore the result of the expression will be counted. 
    1 and 2 are effectively the same - you replace a null value in your column with 0 and each query only selects rows with a null column value.  The count of non-null values of your expression is therefore 2 - the number of rows in your resultset.
    3 is the number of rows in the resultset since you supplied "*" instead of a column.  The presence of nulls is irrelevant as documented.
    4 is the number of non-null values in the resultset since you DID supply a column.  Your resultset had no non-null values, therefore the count is zero.

  • How to get the data by excluding the columns which are having null values

    I have a table with 10 columns , 3 columns are having all null values . I want to retrive the data by excluding these 3 columns. That means output table should contain only 7 columns .
    Can u give a query on this?
    Thanks,
    Mahesh

    select <list of column with not null values>
      from table_nameThat is you need to specify the column name.

  • Any method of ole2 to count the no. of rows in excel worksheet ??

    Dear all,
    want to generate a for 1..n loop structure to access the excel worksheet.
    iam using ole2 to upload data from excel to oracle.
    rest is fine..
    till now iam arbitrarily inputting a value as a count from forms to run the loop.
    want to know is there any method of ole2 to count the no. of rows in excel worksheet...???
    regards,

    If you have purchase order number in your cube then you can use the easiest method of all of counting -- a calculated key figure with exception aggregation.
    Create a CKF and add any basic key figure to it from your cube (basic means a key figure from the cube, not another CKF or RKF).  If you're using the 3.x query designer then click the Enhance button and set the exception aggregation to Counting All Values.  If you're using the 7.0 query designer then click on the Aggregation tab and switch the Exception Aggregation to Counter for All Detailed Values.  With either query designer set the reference characteristic to your PO number characteristic.  This CKF will count the number of PO documents.
    See this document for step-by-step instructions:  [How to... count the occurrences of a characteristic relative to one or more other characteristics|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7e58e690-0201-0010-fd85-a2f29a41c7af].

  • How to replace NULL values from main table

    Dear all,
    I like to remove the NULL values from a main table field. Or the question is how to replace any part of the string field in MDM repository main table field.
    e.g.   I have a middle name field partly the value is NULL in some hundreds of records, I like to replace NULL values with Space
    any recommendation.
    Regards,
    Naeem

    Hi Naeem,
    You can try using Workflows for automatically replacing NULLs with any specific value.
    What you can do is: Create a workflow and set trigger action as Record Import, Record Create and Record Update. So, that whenever any change will occur in the repository; that workflow will trigger.
    Now create an assignment expression for replacing NULLs with any specific value and use that assignment expression in your workflow by using Assign Step in workflow.
    For exiting records, you will have to replace NULLs manually using the process given by Preethi else you can export those records in an Excel spreadsheet which have NULLs and then replace all NULLs with any string value and then reimport those records in your MDM repository.
    Hope this will solve your problem.
    Regards,
    Varun
    Edited by: Varun Agarwal on Dec 2, 2008 3:12 PM

  • Null values coming from JSON

    Ok. heres whats going on. I have a bunch of charts all with
    two series , demand and baseline. About half of them have a null
    value for the last value in demand and of the half 2 have null for
    the entire baseline.
    my problem is one of the afore mentioned 2 charts will not
    show up (chart shows but without lines) unless I iterate through
    and set all null values to zero in the baseline series. Then
    baseline will lie on the x axis(BAD) and demand will show
    correctly(missing the last value because it null, GOOD)
    my question is why? why does demand disappear when baseline
    values are null? here is some code to maybe help you out
    quote:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:myComp="*"
    layout="vertical" viewSourceURL="srcview/index.html"
    preinitialize="srv.send();" uid="theApp">
    <mx:Script>
    <![CDATA[
    import mx.charts.series.LineSeries;
    import mx.charts.chartClasses.Series;
    import mx.charts.AxisRenderer;
    import mx.charts.CategoryAxis;
    import mx.controls.HorizontalList;
    import mx.containers.Panel;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    import com.adobe.serialization.json.JSON;
    import mx.controls.Alert;
    import mx.utils.ObjectUtil;
    [Bindable]private var ercotDem:Array = new Array();
    [Bindable]private var ercotBase:Array = new Array();
    [Bindable]private var times:Array = new Array();
    private function onJSONLoad(event:ResultEvent):void{
    try{
    // ---- i know this json stuff works.
    // ---- i have printed out the data and cheaked
    // ---- to make sure its goign into the array correctly
    // ---- and i use it all over the place in other files
    var rawData:String = String(event.result);
    var jsonOBJ:Object = (JSON.decode(rawData) );
    ercotDem = jsonOBJ.ERCOT.demand as Array;
    ercotBase = jsonOBJ.ERCOT.baseline as Array;
    times = jsonOBJ.times as Array;
    } catch(err:Error){
    Alert.show(err.message);
    private function popup():void{
    Alert.show("Fail!!");
    ]]>
    </mx:Script>
    <!-- other charts here too -->
    <mx:Panel title="Ercot Demand" height="300" width="600"
    layout="horizontal">
    <mx:LineChart id="linechart_ercot" height="100%"
    width="100%"
    showDataTips="true" dataProvider="{times}"
    mouseSensitivity="50">
    <mx:horizontalAxis>
    <mx:CategoryAxis />
    </mx:horizontalAxis>
    <mx:horizontalAxisRenderer>
    <mx:AxisRenderer canDropLabels="true" canStagger="true"
    />
    </mx:horizontalAxisRenderer>
    <mx:series>
    <mx:LineSeries displayName="Ercot Baseline"
    dataProvider="{ercotBase}" />
    <mx:LineSeries displayName=" Ercot"
    dataProvider="{ercotDem}" />
    </mx:series>
    </mx:LineChart>
    </mx:Panel>
    <mx:HTTPService id="srv" resultFormat="text"
    showBusyCursor="true"
    url="--myserver--"
    result="onJSONLoad(event)" fault="popup()" />
    </mx:Application>
    keep in mind this is only one panel theres about 9 and all of
    them work as expected and the code is all the same.
    any ideas?

    no one has any ideas?

  • NULL values are inserted into interface table for read only columns

    Hi, I developed a custom Integrator where some of the columns has to be displayed as read only in the layout. I am using SQL content to populate the data. When I upload the data NULL values are inserted into table interface? Is there any work around for this?
    Thanks
    Edited by: user593879 on Jan 12, 2010 7:21 PM

    Doesn't WebADI drive you insane at times?
    I must say, when it's all working it looks great and it is very user friendly (end-user that is, NOT for developers!) but before you get to that stage… please please Oracle invest some time making Web ADI a bit more logical an coherent, get the obvious bugs out, please let us not have to update BNE tables anymore to get things done.
    Anyway, I sorted this one out by setting the Width to zero (0) in the Layout. HTH.

  • Migrating NULL values in tables from oracle to MS SQL

    Hi,
    I am migrating Oracle 11g database to MS SQL server 2014 using SSMA.
    Currently, when I migrate data, all (null) values in oracle tables are migrated as NULL to SQL.
    However, I want to migrate null values in oracle tables to blank space in SQL.
    Is it possible?
    Is there any setting in SSMA which supports this?
    Thanks.

    Hi ManiC24m,
    In SSMA, there is no setting we can modify to migrate null values in Oracle tables to blank space in SQL  Server. As Prashanth’s post, after the migration, you can replace the null values with blank space via the following Transact-SQL statements in
    SQL Server.
    USE <DatabaseName>
    Go
    UPDATE <TableName> SET <ColumnName>=''
    WHERE <ColumnName> IS NULL
    Thanks,
    Lydia Zhang

Maybe you are looking for

  • Apple TV failing to reconnect - why it happens

    As I reported a few days ago (before the thread was locked...) my AppleTV would lose its connection with my server PC every time the PC was shut down and restarted, and would need to be deleted from within iTunes and reestablished every time. In case

  • ESATA Kernel Panics in Safari 5.1.7 (OSX 10.7.4)

    I'm experiencing kernel panics whenever attempting to load drives using the browser-based interface for the HighPoint Technologies RocketRAID Quad eSATA 6 Gbit/s for Mac controller. This began occurring immediately after updating to Safari 5.1.7 (OSX

  • Deploying BMP Entity Bean with primary key calss

    Hi, I am using EJB 2.0 with and websphere studio 5.0 and database is sql server 2000. My BMP Entity bean has a primary key class.From my client I am invoking the Entity Bean by calling it's findbyprimarykey method. The home interface of my findbyprim

  • Serializing XML Documents(not Java Serialization)

    Hi, Iam looking for a class that can serialize the XML documents. Heres the problem in detail: - I need to create an XML String from scratch taking data from a database. - I created the XML Document adding the childs and attributes. - I need an XML s

  • How to decide MRP controllers

    Hi, My client has five plants. Client manufactures 4 different products. Some raw materials are common for few products. First doubt is I am not able to decide what solution to give on how many MRP controllers should be made? Next, in material master