CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Grid with custom SQL with group by is not working correct

Print topic Send  topic

Author Message
jukhooa

Posts: 5
Posted: 05/13/2005, 1:07 PM

Hi,

I have the following issue.

1. Created a simple grid.
2. Datasource is the following SQL statement:

select FROM_DAYS(TO_DAYS(vdate)) as day, COUNT(*)
from logging group by day;

3. It should give a list of all the dates (without the timestamp) and the hits for that day. In MySql the query is working perfectly.
4. But when I create th pages I get the following error during runtime:

Database error: Invalid SQL: SELECT COUNT(*) FROM logging group by day;
MySQL Error: 1054 (Unknown column 'day' in 'group statement')
Session halted.

So this means that CCS changed my SQL query and there for it is not functioning.

Doing ds->CountSQL(....) did not help me here in the before build select event.

What am I doing wrong? Does someone have a workaround?

Kind regards, Anand.

_________________
Cheers,
Anand
View profile  Send private message
mrachow


Posts: 509
Posted: 05/17/2005, 4:28 AM

I'm not completely sure but I think Studio had not changed your SQL statement but the statement you see is the one Studio creates for itself to compute the number of records for the grid.
In doing that Studio removes the slected columns and substitues them by count(*) changing nothing else.

Sorry but not knowing what to do at the moment.
_________________
Best regards,
Michael
View profile  Send private message
jukhooa

Posts: 5
Posted: 05/17/2005, 4:38 AM

Michael,

Yes that could be the case. I now have the workround that during record insert I use the sql currdate() in a separate field and I use this field for the group by which works correct. Hope that in feature release of codecharge studio the handeling for "complex" sql statements will be improved.

Regards, Anand.
_________________
Cheers,
Anand
View profile  Send private message
peterr


Posts: 5971
Posted: 05/17/2005, 10:37 AM

ds->CountSQL should work. I recommend focusing on debugging that issue. Any SQL complexity is OK, except for the Count, since simlpy adding the COUNT clause to any SQL doesn't always work. Not sure if that can be improved.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Ronald
Posted: 05/22/2005, 10:39 AM

Use the BeforeExecuteSelect event to overwrite the CodeCharge CountSQL and write your own CountSQL.
It should be something like:

select COUNT(day), FROM_DAYS(TO_DAYS(vdate)) as day
from logging group by day

It is necessary to define "day" before you can group it. A simpler and more flexible solution would be to store the date and the time in separate columns.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.