My application has many related tables. Each table represents a certain type of billed time. Below is a sample of data from 2 of the tables. All the other tables have the same columns with the last column being the unique time type. I want to count(distinct(studentid) for the "DirectConsult" table only. I tried this if(sum(direct_consult)>0,count(distinct(studentid)),0) , but it didn't work. The if statement returned the count of all unique studentids. I just want the count of unique studentids in the table "DirectConsult". I hope someone has a suggestion. Thanks.