Saturday, May 31, 2008

NVL For Correct Counts

If you're matching on fields that have any possibility of being null, make sure you code them with the NVL function. If you don't, your count will not be correct.
Select Count(*)
From Client B
Join Account A
On a.Code = b.Retail_Num
Where Nvl(a.Name ,' ') = Nvl(b.Client_Name ,' ')
And Nvl(a.State,' ') = Nvl(b.Client_State,' ')
And Nvl(a.Zip ,' ') = Nvl(b.Client_Zip ,' ');

No comments:

Post a Comment