i running update query, , hoping update table hold value of 0 instead of displaying null when count 0. how can updated force table show 0 when count returned 0?
set @sql = 'update cra set mastercounts = te.lc #tbl_test cra join ( select ,count(case when recordid < 1 0 else recordid end) lc ,employeename productioninformaiton salestatus = (''approved'', ''shipped'') group employeename ) te on cra.[storename] = te.[storename] , cra.[employeename] = te.[employeename]' exec (@sql)
maybe field "recordid" returning null in cases, makes count(null) return null well. try replacing
count(case when recordid < 1 0 else recordid end) lc with
count(case when isnull(recordid, 0) < 1 0 else isnull(recordid, 0) end) lc
Comments
Post a Comment