informix replace null value with 0 in select
c#, informix
Solution
At first you should create simple query with simple db table, some values and requested result that clearly shows your problem.
Part 1: I want replace null value with 0
To change NULL into some value you can use `NVL()` function. Documentation says: The NVL expression returns different results, depending on whether its first argument evaluates to NULL.
Examples:
SELECT fld, NVL(fld, 0) FROM ...
Part 2: and if not null i want to count the data
SELECT COUNT(*) FROM ... WHERE fld IS NOT NULL
Problem
I want replace null value with 0 and if not null i want to count the data ?? ``` sql = "SELECT b.start,COUNT(a.resourceid) " + "FROM t1 b,agentconnectiondetail a "+ "WHERE TO_CHAR(a.startdatetime,'%R') >= TO_CHAR(b.start,'%R') AND TO_CHAR(a.enddatetime,'%R') <= TO_CHAR(b.finish,'%R') " + "AND a.resourceid = '"+dr[1].ToString()+"'" + "GROUP BY 1 ORDER BY 1"; ``` that query output is null what must I do ??