CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> ASP

 TIme Calculate - MSACCESS with Virtual SQL in CDstudio3.0

Print topic Send  topic

Author Message
sirichai

Posts: 22
Posted: 02/20/2007, 1:05 AM

Hi,
Anyone can help me about virtual sql statement. My database is MSAccess. My Sql statement is
-------------------------------------------------
SELECT TECHNICIAL_ALLOTED AS SERVICE_PROVIDER,
(SELECT SPNAME FROM SERVICE_PROVIDER WHERE SPCODE=TECHNICIAL_ALLOTED
) AS SP_NAME
,YEAR(DATE_CALLED) AS YEARNO ,MONTH(DATE_CALLED) AS MONTHNO,
SUM(((VISIT_FROM_DT - DATE_CALLED) * 24 + (VISIT_FROM_TIME - TIME_CALLED)
)) AS TOTAL_TIME_VISIT_GART , COUNT(JOB_SHEET.JOB_SHEET_NO) AS NO_OF_JOBS,
SUM(CASE WHEN VISIT_FROM_TIME > TIME_CALLED THEN VISIT_FROM_TIME > TIME_CALLED ELSE
24 + VISIT_FROM_TIME - TIME_CALLED END) AS TOTAL_VISIT_TIME
FROM JOB_SHEET_VISIT_DETAIL INNER JOIN JOB_SHEET ON
JOB_SHEET_VISIT_DETAIL.JOB_SHEET_NO = JOB_SHEET.JOB_SHEET_NO AND JOB_SHEET.JOB_SHEET_NO = JOB_SHEET_VISIT_DETAIL.JOB_SHEET_NO
WHERE TECHNICIAL_ALLOTED='{SPcode}' and YEAR(DATE_CALLED)={Yearno}
GROUP BY TECHNICIAL_ALLOTED,YEAR(DATE_CALLED) ,MONTH(DATE_CALLED)
ORDER BY TECHNICIAL_ALLOTED,YEAR(DATE_CALLED) DESC ,MONTH(DATE_CALLED)
----------------------------------------------

The problem is in field
SUM(CASE WHEN VISIT_FROM_TIME > TIME_CALLED THEN VISIT_FROM_TIME > TIME_CALLED ELSE
24 + VISIT_FROM_TIME - TIME_CALLED END) AS TOTAL_VISIT_TIME

ALL fields in statement data type are DATE/TIME.
ANYONE PLEASE HELP ME.
Regards,
Sirichai


View profile  Send private message
DeanCovey


Posts: 22
Posted: 02/20/2007, 3:14 AM

Have you tested your data inside MS-Access? I'd try writing this query in Access and prove to yourself the that your data is correct and you are able to get the results you want.

If that's try, you can use this new query as your data source instead of trying to write your own sql statement.

View profile  Send private message
sirichai

Posts: 22
Posted: 02/21/2007, 7:22 PM

Hi DeanCovey,
Thanks for your advice. Now It success for virtual SQL. I wrote in ACCESS after that use in Virtual SQL.

Thanks,
Sirichai
View profile  Send private message

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.