RE: RecordCount of query group

2006-02-28 Thread Ian Skinner
Is it possible to get the RecordCount of cf query group?

cfoutput query=getReord group=Name
   #Name#, #RecordCount#
cfoutput
   #SubName#, #RecordCount#
/cfoutput
/cfoutput

Not automatically the way you are doing it.  You can either do something in the 
query with group functions, or you can count them in your output.

cfoutput query=getReord group=Name
   #Name#
  cfset groupCount = 0
  cfoutput
#SubName#
cfset groupCount = groupCount + 1
  /cfoutput
  GroupCount = #groupCount#
/cfoutput


--
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

-
| 1 |   |
-  Binary Soduko
|   |   |
-
 
C code. C code run. Run code run. Please!
- Cynthia Dunning

Confidentiality Notice:  This message including any
attachments is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the
intended recipient, please contact the sender and
delete any copies of this message. 




~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233644
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: RecordCount of query group

2006-02-28 Thread Baz
You could create a counter:

cfset OuterRecordcount=0 /
cfoutput query=getReord group=Name
   cfset OuterRecordcount=OuterRecordcount+1 /
   #Name#, #RecordCount#
cfoutput
   #SubName#, #RecordCount#
/cfoutput
/cfoutput

Baz


-Original Message-
From: j s [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 28, 2006 11:11 AM
To: CF-Talk
Subject: RecordCount of query group

Is it possible to get the RecordCount of cf query group?

cfoutput query=getReord group=Name
   #Name#, #RecordCount#
cfoutput
   #SubName#, #RecordCount#
/cfoutput
/cfoutput

what is returned it the total RecordCount of the query and not the count of
SubNames in each group.

Total RecordCount: 4

Name1
  SubName1
  SubName2
(total SubName count 2 what is returned is 4)



~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233645
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RecordCount of query group

2006-02-28 Thread Rick Root
Baz wrote:
 You could create a counter:

That's how I generally do it but if you need the count at the beginning 
of the group, or during the output of the group, then your alternative 
would be to pass the query to a UDF that you write whose sole purpose is 
to determine the count of the current group, using a query of queries.

cffunction name=getGroupCount
   cfargument name=qry type=query required=yes
   cfargument name=fieldName type=string required=yes
   cfargument name=fieldValue type=string required=yes
   cfargument name=sqltype type=string required=yes

   cfquery name=qry2 dbtype=query
 select count(*) AS CNT
 from qry
 where #fieldname# = cfqueryparam cfsqltype=#sqltype# 
value=#fieldValue#
   /cfquery
   cfreturn qry2.CNT
/cffunction

Then, in your output, you can just call the UDF to get the record count.

Might have to put some logic around it to only call it once per grouping...

Rick



~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233705
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: RecordCount of query group

2006-02-28 Thread Rick Root
Alternatively, you could probably get the group count into the query 
result set itself by using

SELECT name, subname, count(subname) as subnameCount, cola, colb, colc
from tableName
order by name, subname
group by name, subname, cola, colb, colc

Rick

j s wrote:
 Is it possible to get the RecordCount of cf query group?
 
 cfoutput query=getReord group=Name
#Name#, #RecordCount#
 cfoutput
#SubName#, #RecordCount#
 /cfoutput
 /cfoutput
 
 what is returned it the total RecordCount of the query and not the count of 
 SubNames in each group.
 
 Total RecordCount: 4
 
 Name1
   SubName1
   SubName2
 (total SubName count 2 what is returned is 4)
 
 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:233706
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54