2015-04-07 102 views
1

這是我的查詢,它給MySql中的SQL手動語法錯誤。MySql中的查詢語法錯誤

select 
count(case when v.created_at = vv.minva then user_id) as num_new_users 
from bills v 
join (select user_id, min(created_at) as minva from bills t group by user_id) vv 
on v.user_id = vv.user_id 

有人可以幫我解決這個問題嗎?

+0

該案件不正確。 – jarlh

回答

1

case statementend

select 
count(case when v.created_at = vv.minva then user_id end) as num_new_users 
from bills v 
join (select user_id, min(created_at) as minva from bills t group by user_id) vv 
on v.user_id = vv.user_id 
2

結束你忘了CASE語句中使用end

select 
count(case when v.created_at = vv.minva then user_id end) as num_new_users 
from bills v 
join (select user_id, min(created_at) as minva from bills t group by user_id) vv 
on v.user_id = vv.user_id