It's your FROM statement; you're not joining counties, districts, schools
and histories in any way, so you're getting a cartesian product set.

You need some join qualifiers along the likes of 

vv1_Counties INNER JOIN vv1_districts on vv1_districts.countyID =
vv1_Counties.countyID (or whatever field you're using to link those two).

-----Original Message-----
From: John Wilker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 28, 2001 12:34 PM
To: CF-Talk
Subject: Query boggle


Hey guys and gals,

    This is probably something I'm just not seeing clearly but the below
query is supposed to bring my back a count of records grouped by sex.
I've been staring at this query so long I'm not seeing anything. It finds
the right records. The data I have has a male and a female record and both
are found by this query. Yet when I output TotalPerGender I get 808233984

Much obliged.

<CFQUERY DATASOURCE="#dbname#" NAME="qGetSectionTwo">
 SELECT
      COUNT(ChildIdentity.ChildID) AS TotalPerGender,
      ChildIdentity.ChildGender AS Gender
 FROM
      vvl_Counties ,
      vvl_districts,
      vvl_schools,
      ChildSchoolHistory CSH,
      ChildIdentity INNER JOIN ChildResidence ON ChildIdentity.ChildID =
ChildResidence.ChildID
 WHERE
  ChildIdentity.ChildID = CSH.ChildID
      AND Year(CSH.SchoolYearStartDate) BETWEEN #FORM.SchoolYear#
      AND CSH.schooltitle1 = 1<!--- Not sure what value --->
      AND CSH.LastAttendDate IS NULL
      AND ChildResidence.ResidenceCounty = '#FORM.counties#'
 GROUP BY ChildIdentity.ChildGender
 ORDER BY ChildIdentity.ChildGender
</CFQUERY>

J.

John Wilker
Web Applications Consultant
Allaire Certified ColdFusion Developer

Office: 909-943-8428
www.red-omega.com

15 people are known to have been crushed to death tilting soda
machines towards them in order to receive free soda.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to