Hi there. I am having the hardest time with this, so I hope someone can give me some advice! I have a bunch of SQL queries on one ASP page that I know can be combined into 1 query, I just can&#039;t figure out how. The SELECT and FROM statements are the same, but the parameters in the WHERE clause change. So for example, the page lists a number of vaccines, I need to find the # of distinct patients who&#039;ve received that vaccine, and the number of times the vaccine has occurred (the same vaccine given on the same day doesn&#039;t count). The WHERE clause parameters change for each vaccine. Here&#039;s some code - this is a query for one of the vaccines. I use essentially the same query just with different WHERE clauses for each vax (that&#039;s what I need to change!):<BR><BR>"SELECT COUNT(DISTINCT per_id) AS PID, stat_dtAS SDate " &_<BR>"FROM STAT INNER JOIN VACCINATION ON STAT.id = VACCINATION.id " &_ <BR>"INNER JOIN HS ON STAT.id = HS.id " &_<BR>"WHERE (STAT.status_cd = 9) AND (STAT.role_cd=3) " &_<BR>"AND (hsop.p_id IN(SELECT p_id FROM p WHERE p_birth_dt &#062;= &#039;" & startDate & "&#039; and p_birth_dt &#060;=&#039;" & EndDate & "&#039;)) " &_ <BR><BR>*****here&#039;s where the parameter&#039;s change depending on the vax****<BR>"AND (hs.proc_cd IN(8700, 8701, 8711)) " &_<BR>"AND (stat.status_dt &#060;= &#039;"& strTwoYear & "&#039;) " &_<BR>"AND (stat.status_dt &#062;=&#039;"& strOneYear & "&#039; and stat.status_dt &#060;= &#039;"& strTwoYear & "&#039;) " &_<BR>"AND (stat.status_dt IN (SELECT DISTINCT stat.status_dt FROM stat " &_<BR>"INNER JOIN per ON stat.id=per.id WHERE per.p_id=&#039;"& strPID & "&#039;)) " &_<BR>****group by clause is the same*****<BR>"GROUP BY stat.status_dt"<BR><BR>I define the ASP variable used in the query earlier in my page. The different vaccines are determined by the med_proc_cd, but when I tried using an if/then statement on that code, my counts got all screwed up - since I had to put the code in the SELECT and GROUP BY statements, it of course gave each code a separate row.<BR><BR>I would greatly appreciate any help. Thanks in advance.