Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

How to read an output of the group by query in cold fusion.

I am developing a report in cold fusion with ms access database.
and I want to run a query through a cold fusion page .
My query is
select source,count(id) from table_name group by source.
I don't know how to read the output of this query in cold fusion.

0
gaby22
Asked:
gaby22
  • 3
  • 3
1 Solution
 
mrichmonCommented:
<cfquery datasource="yourdsn" name="access_query">
SELECT Source, COUNT(ID) AS SourceCount FROM table_name GROUP BY Source
</cfquery>

<cfoutput query="access_query">
#Source# --> #SourceCount#<br>
</cfoutput>
0
 
eclipse2kCommented:
i guess, your problem is to get the count??? you should be able to give a name to the count variable.


Example 1)
select source,count(id) As 'sourcecount' from table_name group by source

Example 2)
select source,count(id) As sourcecount from table_name group by source


the only difference between example 1 and 2 is the ' around sourcecount, i am working with microsoft sql and there are both allowed, not sure with access, you should try it.


CF:

<cfoutput query="myquery">
 Source: #Source#, Occurance: #sourcecount# times
</cfoutput>



eclipse2k
0
 
eclipse2kCommented:
hello mrichmon, just faster again..? i need more training.. :)
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
mrichmonCommented:
:o)

Happens all the time that two people post the same thing at almost the same time
0
 
eclipse2kCommented:
hello mrichmon,

i dont understand why finally i got the accepted answer? sorry mrichmon...
you should be the one.

now i finally qualifed for the premium services for beeing one of the experts :) 10k points, finally :)

oh, i guest i should stop chit chatting in the Question Threads. Sorry, was the last one. Probaby :)
0
 
mrichmonCommented:
no problem - I don't care abou the points just about the user getting the answer.
Glad you got the premium services  :o)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now