String sql = "select count(*) as cnt from (
select tab1.* from POInventory tab1
union all
select tab2.* from icinventory tab2
) a
left join T_ICItem b on a.fItemID = b.fItemID
left join T_Stock c on c.fitemID = a.FStockID
where c.FDeleted = 0 and b.FDeleted = 0 "
Table tCount = SQL.select(cSql,null, DATA_MODEL);
int num = tCount.iterator().next().getInt("cnt");