This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
After narrowing down the problem, here is what I am left with that works.
mysql = "select "+field1+",count(*) as count from mytable where ? is not null and ( "+field1+" like '%@abc.com' or ? like '%@def.com' ) and myfield = ? and validate_date > date_sub(NOW(), Interval "+dateRange+" ) group by "+field1;