2012-05-15 24 views
0

有人可以幫我在這一分鐘的錯誤。 我寫了這個,(這是不工作),mysql查詢中的小錯誤

SELECT sum(case when SD.order_id>0 then 1 else 0 end) as SD.customer_id 
FROM tbl_order_lead_send_detail SD 

,但此查詢工作正常。

SELECT sum(case when order_id>0 then 1 else 0 end) as customer_id 
FROM tbl_order_lead_send_detail 

回答

2

你的問題是這樣的:

as SD.customer_id 

你可能會考慮寫:

as `SD.customer_id` 

編輯

監守你不能在列名.。如果你有他們作爲一個字符串它的作品。 .用於表中的列。

+0

感謝。它有幫助。 – Thompson

+0

沒問題。樂意效勞 – Arion

1

請嘗試:

SELECT sum(case when SD.order_id>0 then 1 else 0 end) as customer_id FROM tbl_order_lead_send_detail, SD