Hello, belac:
This is the coldfusion code to insert into your ColdFusion page:
<table width="85%" bgcolor="#999999" border="0" cellpadding="0" cellspacing="0">
<cfquery name="product_query" DBType="query">
SELECT *, count(ID) as Times
FROM ProductSearch
GROUP BY Word
</cfquery>
<tr>
<td bgcolor="white"><b>Word</b></td>
<td bgcolor="white"><b>Times</b></td>
</tr>
<cfoutput query="product_query">
<tr>
<td valign="top" bgcolor="white">#Word#</td>
<td valign="top" bgcolor="white">#Times#</td>
</tr>
</cfoutput>
</table>
If you have any problem integrating it, please, don't hesitate to
request for any clarification, I'm here to help you until you get what
you need.
Regards. |
Request for Answer Clarification by
belac-ga
on
08 Dec 2003 11:25 PST
Hello joseleon,
Thank you for your prompt reply. However I receive the following error
when I run the code:
Here is my query written in the format you sent. The table and fields
are named different, but contain the same as my orginal post:
<cfquery name="search_queries" datasource="#ds#">
SELECT *, count(QueryID) AS QueryCount
FROM MasQueries
GROUP BY QueryTerm
</cfquery>
I receive the following error:
Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Column
'MasQueries.QueryID' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.
The QueryID is the same as the ID field in my orginal post. It is the
Primary Key (INT TYPE) for each record.
|
Clarification of Answer by
joseleon-ga
on
08 Dec 2003 11:29 PST
Hello, belac:
Ok, is there any way you can post/export your database table so I can
test it here with the real table description? If not, just tell me and
I will try to reproduce the problem here.
Regards.
|
Clarification of Answer by
joseleon-ga
on
08 Dec 2003 12:06 PST
Hello, belac:
Try with this SQL instead:
SELECT QueryTerm, count(QueryID) as QueryCount
FROM MasQueries
Group by QueryTerm
it works in Access, I'm going to try with an SQL Server table.
Regards.
|
Request for Answer Clarification by
belac-ga
on
08 Dec 2003 12:11 PST
Can Iu email you or can I post my email address so I can give you the
FTP info to grab the file?
|
Clarification of Answer by
joseleon-ga
on
08 Dec 2003 12:21 PST
Hello, belac:
No, I'm sorry, we can't communicate privately due the Researcher
Guidelines and Google Terms of Service that prevent us to do so.
Please, try my last query because I have just tested it on SQL server
and it works ok. If it still doesn't work I will post here a private
upload page for you to upload the database so I can work on it, but
first, please, try the last query as the upload method is the last
resort.
Regards.
|
Request for Answer Clarification by
belac-ga
on
08 Dec 2003 12:34 PST
Hello Jose,
Thanks, it worked. However, since I can't use the primary key
"QueryID" to number the records in the output how can I display the
recordcount for the query next to each record?
Like:
1. CD player 2
2. Television 3
3. MP3 Player 1
4. DVD Player 4
etc...
|
Clarification of Answer by
joseleon-ga
on
08 Dec 2003 12:54 PST
Hello, belac:
If you use the cfoutput tag, you can use the CurrentRow var that is
set to the number of the row is being echoed to the browser:
<cfoutput query="a">
<tr>
<td valign="top" bgcolor="white">#CurrentRow#</td> <td
valign="top" bgcolor="white">#QueryTerm#</td>
<td valign="top" bgcolor="white">#QueryCount#</td>
</tr>
</cfoutput>
I hope this is what you were looking for.
Regards.
|
Request for Answer Clarification by
belac-ga
on
08 Dec 2003 13:38 PST
Great, thanks for all your help. How can I find you again for
questions in the future? I need fast response time like this.
|
Clarification of Answer by
joseleon-ga
on
08 Dec 2003 15:02 PST
Hello, belac:
That's very kind of you, you can post questions directly to me by
using "For joseleon only" as subject.
Regards.
|