0
好,我快要放棄這一個COUNT(DISTINCT(CASE當尋找功能不列MySQL的
當我運行下面的查詢,我得到「錯誤代碼:。1305 FUNCTION statpurchase .playerId does not exist「。我沒有得到一個行號,但我強烈懷疑COUNT(DISTINCT(WHEN子句)
該查詢試圖計算在給定的購買的唯一playerIds的百分比一天的一段時間statpurchase.playerId是一個有效的列名稱
這是一個可憐的人責怪他的工具,但我懷疑它可能是一個解析器錯誤類似於this one。
delimiter $$
CREATE PROCEDURE `percentUniquesPurchasing`(in startTime datetime, in endTime datetime, in placeId int)
BEGIN
declare total_uniques int;
declare iOS_uniques int;
declare desktop_uniques int;
declare i datetime;
set i = startTime;
CREATE TEMPORARY TABLE results (
theday datetime,
total float,
iOS float,
desktop float
);
while(i < endTime + INTERVAL 1 DAY) do
select count(distinct(statplaysession.playerId)),
count(distinct(case when touchInterface = 1 then statplaysession.playerId else null end)),
count(distinct(case when touchInterface = 0 then statplaysession.playerId else null end))
into
total_uniques, iOS_uniques, desktop_uniques
from rbxstats.statplaysession
where
statplaysession.start > i and
statplaysession.start < i + INTERVAL 1 DAY and
statplaysession.placeId = placeId;
insert into results (theday, total, iOS, desktop)
select i,
if(total_uniques > 0, count(distinct(statpurchase.playerId))/total_uniques, 0),
if(iOS_uniques > 0, count(distinct(statpurchase.playerId(case when touchInterface = 1 then statpurchase.playerId end)))/iOS_uniques, 0),
if(desktop_uniques > 0, count(distinct(statpurchase.playerId(case when touchInterface = 0 then statpurchase.playerId end)))/desktop_uniques,0)
from rbxstats.statpurchase where
statpurchase.timestamp > i and
statpurchase.timestamp < i + INTERVAL 1 DAY and
statpurchase.placeId = placeId;
set i = i + INTERVAL 1 DAY;
end while;
select * from results;
drop temporary table results;
END$$
OH SNAP使用statpurchase.playerId作爲一個函數,它似乎沒有成爲其列。你是對的。非常感謝! –