我知道这不是一个应该在这里提出的问题。请帮我解决这个问题。
我尝试在下面的查询中使用case语句,但是我找不到我在其中所做的错误。请帮助我..
SELECT
tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord
(CASE WHEN tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord == 'NVA' THEN 'NON_ValueAccessory'),
COUNT(tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord) Ccord_count
FROM
tsc_accessory_details_for_repaired_and_qc_pass_phone_list
WHERE
tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord = 'NVA'
GROUP BY
tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord
我收到如下错误
SQL] SELECT tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord (例如tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord ==' NVA'那么' ok'), COUNT(tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord)Ccord_count 从 tsc_accessory_details_for_repaired_and_qc_pass_phone_list 哪里 tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord =' NVA' 通过...分组 tsc_accessory_details_for_repaired_and_qc_pass_phone_list.Ccord
[Err] 1064 - 您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在' ==' NVA'附近使用正确的语法。然后好的'), COUNT(第3行的tsc_accessory_details_for_repaired_and_qc_pass_phon'
答案 0 :(得分:1)
你的桌名太长了。如果缩短名称,您必须使用较短的名称或仅使用同义词。试试这个查询 -
SELECT ta.Ccord
, (CASE WHEN ta.Ccord = 'NVA' THEN 'NON_ValueAccessory' END)
, COUNT(ta.Ccord) Ccord_count
FROM tsc_accessory_details_for_repaired_and_qc_pass_phone_list ta
WHERE ta.Ccord = 'NVA'
GROUP BY ta.Ccord, ta.Ccord
答案 1 :(得分:0)
我可以在这里看到一些错误。
end case