Jac*_*ack 0 mysql coldfusion coldfusion-9
我使用以下代码,并想知道为什么我收到"查询查询"错误?
<cfquery name="findpercentage" datasource="#mydatasource#">
SELECT
Count(TableId_bi) AS Total_Events
,Sum(CASE WHEN 'OPEN' = Event_vch THEN 100 END) / Count(*) AS OPENS
,Sum(CASE WHEN 'BOUNCE' = Event_vch THEN 100 END) / Count(*) AS BOUNCE
,Sum(CASE WHEN 'DEFERRED' = Event_vch THEN 100 END) / Count(*) AS DEFERRED
,Sum(CASE WHEN 'DROPPED' = Event_vch THEN 100 END) / Count(*) AS DROPPED
,Sum(CASE WHEN 'DELIVERED' = Event_vch THEN 100 END) / Count(*) AS DELIVERED
,Sum(CASE WHEN 'PROCESSED' = Event_vch THEN 100 END) / Count(*) AS PROCESSED
,Sum(CASE WHEN 'SPAMREPORT' = Event_vch THEN 100 END) / Count(*) AS SPAMREPORT
FROM
mydatabase;
</cfquery>
<cfdump var="#findpercentage#">
<cfquery name = "piechartdisplay" dbtype = "query">
SELECT OPENS as Ecount, 'Open' as type
from findpercentage
UNION
SELECT BOUNCE as Ecount, 'Bounce' as type
from findpercentage
UNION
SELECT DEFERRED as Ecount, 'Deferred' as type
from findpercentage
UNION
SELECT DROPPED as Ecount, 'Dropped' as type
from findpercentage
UNION
SELECT DELIVERED as Ecount, 'Delivered' as type
from findpercentage
UNION
SELECT PROCESSED as Ecount, 'Processed' as type
from findpercentage
UNION
SELECT SPAMREPORT as Ecount, 'Spamreport' as type
from findpercentage
</cfquery>
<cfdump var="#piechartdisplay#">
Run Code Online (Sandbox Code Playgroud)
查询的第一部分是在网页上转储属性,但是,"piechartdisplay"的第二次转储尝试正在生成查询或查询错误.错误描述如下:
Error Executing Database Query.
Query Of Queries syntax error.
Encountered "DEFERRED. Incorrect Select List, Incorrect select column,
The error occurred in C:\Path\myfile.cfm: line 39
37 :
38 :
39 : <cfquery name = "piechartdisplay" dbtype = "query">
40 :
41 : SELECT OPENS as Ecount, 'Open' as type
SQL SELECT OPENS as Ecount, 'Open' as type from findpercentage UNION SELECT BOUNCE as Ecount, 'Bounce' as type from findpercentage UNION SELECT DEFERRED as Ecount, 'Deferred' as type from findpercentage UNION SELECT DROPPED as Ecount, 'Dropped' as type from findpercentage UNION SELECT DELIVERED as Ecount, 'Delivered' as type from findpercentage UNION SELECT PROCESSED as Ecount, 'Processed' as type from findpercentage UNION SELECT SPAMREPORT as Ecount, 'Spamreport' as type from findpercentage
Run Code Online (Sandbox Code Playgroud)
我必须传递上面查询中的数据(在它开始运行之后没有错误),如下所示,这就是为什么我像上面那样编写我的QoQ:
<cfset dataItem =[
'#type#', '#Ecount#'
]>
Run Code Online (Sandbox Code Playgroud)
请告诉我这里错了.
| 归档时间: |
|
| 查看次数: |
82 次 |
| 最近记录: |