J
Jeff Uchtman
Here are 4 different MS SQL query's:
Set rsVer = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
Verified_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code Group BY p.Locality_Code, p.Name ORDER BY
p.Locality_Code"
rsVer.Open strSQL, Conn
Set rsPetA = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetA_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetA = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet1.Open strSQL, Conn
Set rsPetB = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetB_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetB = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet2.Open strSQL, Conn
Set rsPetC = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetC_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetC = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet3.Open strSQL, Conn
Set rsPetD = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetD_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetD = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet4.Open strSQL, Conn
As you can see all are tapping the same tables for results but the 2nd, 3rd,
and 4th are filtering by a table if checked. How can I combine all 4 into 1
with the filters involved? Each query give me a result from 93 variables
showing Locality_Code (1 - 93), Name (Name of each Locality_Code) and then
the count, first total, then filtered by PetA, PetB, PetC, PetD. I'd like
to do a loop through to display the results but not sure if thats the best
way.
Thanks
Jeff
Set rsVer = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
Verified_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code Group BY p.Locality_Code, p.Name ORDER BY
p.Locality_Code"
rsVer.Open strSQL, Conn
Set rsPetA = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetA_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetA = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet1.Open strSQL, Conn
Set rsPetB = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetB_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetB = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet2.Open strSQL, Conn
Set rsPetC = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetC_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetC = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet3.Open strSQL, Conn
Set rsPetD = Server.CreateObject("ADODB.Recordset")
strSql = "Select p.Locality_Code, p.Name, Count(c.Locality_Code) as
PetD_Count From County AS p LEFT JOIN Verified as c on
p.Locality_Code=c.Locality_Code and PetD = 1 Group BY p.Locality_Code,
p.Name ORDER BY p.Locality_Code"
rsPet4.Open strSQL, Conn
As you can see all are tapping the same tables for results but the 2nd, 3rd,
and 4th are filtering by a table if checked. How can I combine all 4 into 1
with the filters involved? Each query give me a result from 93 variables
showing Locality_Code (1 - 93), Name (Name of each Locality_Code) and then
the count, first total, then filtered by PetA, PetB, PetC, PetD. I'd like
to do a loop through to display the results but not sure if thats the best
way.
Thanks
Jeff