SELECT
debt.debt_run_number 流水号,
debt.comp_code 项目编码,
debt.comp_allname 项目全称,
debt.area 区域,
debt.company_leader 项目负责人,
debt.current_year 当前年度,
MAX( CASE debt_detail1.history_year WHEN 2017 THEN debt_detail1.history_year_debt ELSE '0' end) 2017年,
MAX( CASE debt_detail1.history_year WHEN 2018 THEN debt_detail1.history_year_debt ELSE '0' end) 2018年,
MAX( CASE debt_detail1.history_year WHEN 2017 THEN '0' WHEN 2018 THEN '0' ELSE debt_detail1.history_year_dept end) 2017年以前
FROM
debt INNER JOIN debt_detail1 ON debt.debt_run_number = debt_detail1.debt_run_number
GROUP BY
debt.debt_run_number ,
debt.comp_code ,
debt.comp_allname ,
debt.area ,
debt.company_leader ,
debt.current_year
chen_fei2928(提问者)select
debt.debt_run_number 流水号,
debt.comp_code 项目编码,
debt.comp_allname 项目全称,
debt.area 区域,
debt.company_leader 项目负责人,
debt.current_year 当前年度,
debt_detail1.history_year 历史年度,
debt_detail1.history_year_debt 历史年度欠款,
MAX(case debt_detail1.history_year when 2017 then debt_detail1.history_year_debt else \'0\') 2017年,
MAX(case debt_detail1.history_year when 2018 then debt_detail1.history_year_debt else \'0\') 2018年,
MAX(case debt_detail1.history_year when 2017 then \'0\' when 2018 then \'0\' else debt_detail1.history_year_dept ) 2017年以前
from debt INNER JOIN debt_detail1 on debt.debt_run_number = debt_detail1.debt_run_number
group by
我这样一直提示我有问题呢?
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \') 2017年,
MAX(case debt_detail1.history_year when 2018 then debt_detail1.hi\' at line 11
chen_fei2928(提问者) 回复 13207222709select
debt.debt_run_number 流水号,
debt.comp_code 项目编码,
debt.comp_allname 项目全称,
debt.area 区域,
debt.company_leader 项目负责人,
debt.current_year 当前年度,
debt_detail1.history_year 历史年度,
debt_detail1.history_year_debt 历史年度欠款,
MAX(case debt_detail1.history_year when 2017 then debt_detail1.history_year_debt else \'0\' END) 2017年,
MAX(case debt_detail1.history_year when 2018 then debt_detail1.history_year_debt else \'0\' END) 2018年,
MAX(case debt_detail1.history_year when 2017 then \'0\' when 2018 then \'0\' else debt_detail1.history_year_debt END) 2017年以前
from debt INNER JOIN debt_detail1 on debt.debt_run_number = debt_detail1.debt_run_number
GROUP BY
还是报错
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'\' at line 19
19行是 group by