...

View Full Version : SQL Query help



dawilis
11-08-2003, 12:57 PM
I know Im giving this forum a workout at the moment thanks for your help

I am trying to get the total records based on this statement, it works because Im not drawing out much info, however I do need to use the last part, the filter on the month, thats not working, as a matter of fact its just ignoring it, as if its not there. any ideas

SQL= "SELECT count(*) as id From NMContact WHERE Age ='"&age&"' AND PolicyId ="&PolicyId&" AND Month ='"&months&"'"

have included below code in its entirity

do while i <= loopcount
' Now loop through the Policies
x = 1
do While x <= policyidmax
age = ageis(i)
amount = 0
policyid = x
SQL1= "SELECT * FROM Health WHERE IDH ="& policyId
rs1.open sql1,con
SQL= "SELECT count(*) as id From NMContact WHERE Age ='"&age&"' AND PolicyId ="&PolicyId&" AND Month ='"&months&"'"
rs2.open SQL,con
' if user does not want the zero entries
if rs2("id") = 0 and noz = 1 Then
x = x + 1
counter = counter + 1
rs1.close
rs2.close
exit do
end if
amount = rs2("id")
%>
<%If (counter Mod 2) Then%>
<tr bgcolor="<%=bgcolour2%>">
<%ELSE%>
<tr bgcolor="<%=bgcolour1%>">
<%End If%>
<td width="33%" height="25"><div align="center"><%=age%><BR>
</div></td>
<td width="33%"><div align="center"><%=rs1("HealthType")%><BR>
</div></td>

<td width="26%"><div align="center"><%=amount%><BR>
</div></td>
<td width="8%"><a href="print.asp?mode=1&msg=1&loop=1&no=<%=noz%>" class="hlink">Print</a> </td>
</tr>
<%
x = x + 1
counter = counter + 1
rs1.close
rs2.close
loop
i = i + 1
' rs.close
'rs1.close
loop
end if
%>

A1ien51
11-08-2003, 02:57 PM
*

jeskel
11-08-2003, 04:28 PM
Are you sure you get a value for the months var? Test this first... get the value then try a response.write.. If the others var are used I don't see why this one wouldn't...

dawilis
11-08-2003, 11:44 PM
This is what the SQL is as an output
there is a field called month and Novemver is in it

SELECT count(*) as id From NMContact WHERE Age ='-15' AND PolicyId =1 AND Month ='November'



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum