2 Replies Latest reply on Sep 21, 2006 1:59 PM by MikerRoo

    recordcount within groupby

    TESS_GEAR Level 1
      I used group attribute within cfoutput tag to group by AType and BType and
      tried to get the record count of Btype group there, but I got all record if I use #TEST.recordcount# within the BType group section.
      how can I get a recordcount just for BType?

      <cfquery name="TEST" datasource="TESTDB">
      ...............
      </cfquery>

      <cfoutput query="TEST" group="Atype">
      <cfoutput group="Atype">
      <cfoutput group="Btype">
      <cfoutput>
      How many records grouped by Btype? #??????#
      </cfoutput>
      </cfouput>
      </cfouput>
      </cfoutput>
        • 1. Re: recordcount within groupby
          Level 7
          There is not automatic ColdFusion feature to get a record count of a
          subset of a query. You can build this into your query or your loop. A
          simple option for your loop would be this. Modify as needed to count
          each inner loop.

          <cfquery name="TEST" datasource="TESTDB">
          ...............
          </cfquery>

          <cfoutput query="TEST" group="Atype">
          <cfoutput group="Atype">
          <cfset BtypeCount total = 0>
          <cfoutput group="Btype">
          <cfset BtypeCount = BtypeCount + 1>
          <cfoutput>
          </cfoutput>
          </cfouput>
          </cfouput>
          BtypeCount Total is #BtypeCount#
          </cfoutput>
          • 2. Re: recordcount within groupby
            MikerRoo Level 1
            Use the attached code.

            Also note that you do not need (or want) to group by Atype twice.