Connecting Tech Pros Worldwide Help | Site Map

Multiple querys OR Querying query

  #1  
Old May 8th, 2009, 01:06 PM
Member
 
Join Date: Mar 2007
Posts: 94
Hi,

I need to produce a report in CF that extracts a range of values repeatedly from a database and displays the record count.

For example I need to extract the recordcount where a record has a PowerRating value of between 0 - 2.9, and 3 - 7.4 and so on.

I can create multiple queries:

Expand|Select|Wrap|Line Numbers
  1. select         ClientFK,
  2.             ResponseLevelFK,
  3.             PowerRating
  4.     from        tblWorkshopsNeil
  5.     where        ClientFK like '%#form.ClientFK#%' 
  6.             and (((tblWorkshopsNeil.PowerRating)>=0 And (tblWorkshopsNeil.PowerRating)<=2.9))
  7.     order by    ClientFK
  8.  
  9.  
  10.     </cfquery>
  11.  
  12.  
  13.     <cfquery datasource="repairmdb" name="qryKWBand2">
  14.     select         ClientFK,
  15.             ResponseLevelFK,
  16.             PowerRating
  17.     from        tblWorkshopsNeil
  18.     where        ClientFK like '%#form.ClientFK#%' 
  19.             and (((tblWorkshopsNeil.PowerRating)>=3 And (tblWorkshopsNeil.PowerRating)<=7.4))
  20.     order by    ClientFK
  21.  
  22.  
  23.     </cfquery>
and just return the recordcounts:

Expand|Select|Wrap|Line Numbers
  1. <cfoutput>#qryKWBand1.RecordCount#</cfoutput></p>
  2.             <p>Number of records returned: <cfoutput>#qryKWBand2.RecordCount#</cfoutput></p>
..but this seems really inefficient, and as I might need to add in further filters (such as breaking down the results by Response Level) very cumbersome.

Is there a way to run a major query then use the basis to perform further queries?

Thanks
Neil
best answer - posted by acoder
Yes, there's a feature in Coldfusion called Query of Queries.
  #2  
Old May 8th, 2009, 08:02 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,517
Provided Answers: 12

re: Multiple querys OR Querying query


Yes, there's a feature in Coldfusion called Query of Queries.
  #3  
Old May 11th, 2009, 09:23 AM
Member
 
Join Date: Mar 2007
Posts: 94

re: Multiple querys OR Querying query


Thanks acoder - great!

Neil
  #4  
Old May 11th, 2009, 10:01 AM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,517
Provided Answers: 12

re: Multiple querys OR Querying query


No problem, you're welcome :)
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to "append" a datatable? Christian Maier answers 6 April 6th, 2006 11:03 AM