SELECT
groupno, indicatorno, indicator, unit, bmntarget,
(SELECT
CASE
WHEN IndicatorReport.indicatorno = 1 THEN SUM(q01a)
WHEN IndicatorReport.indicatorno = 2 THEN SUM(q02a)
WHEN IndicatorReport.indicatorno = 3 THEN SUM(q03a)
WHEN IndicatorReport.indicatorno = 4 THEN SUM(q03a)
WHEN IndicatorReport.indicatorno = 5 THEN SUM(q05a)
END
FROM (
SELECT *
FROM TambonBMN2 LEFT JOIN TambonBMN3 ON TambonBMN3.year = TambonBMN2.year AND
TambonBMN3.villid = TambonBMN2.villid WHERE TambonBMN2.year = 2545 AND
TambonBMN2.villid LIKE 'NULL%' ) res_all
) as result_all
FROM
IndicatorReport
ORDER BY groupno,indicatorno
จะ error ตรง res_all ครับ
ข้อความที่แจ้ง
Msg 8156, Level 16, State 1, Line 16
The column 'year' was specified multiple times for 'res_all'.