我每次運行此查詢時總會得到相同的錯誤。 我試着用簡單的查詢來測試查詢中是否有錯誤。 我也注意到,當我在查詢中使用視圖時發生錯誤。databasename.d.first_column_in_the_table'不在GROUP BY
CREATE OR REPLACE VIEW v_vss_car_wash AS
SELECT
max(r.id) AS id
,d.id AS dealer_id
,d.dealer_code
,d.dealer_name
,count(*) AS total_respondents
,sum(car_washed) AS car_washed -- Car Washed
,count(*) - sum(car_washed) AS car_unwashed -- Car Unwashed
,sum(IF (car_washed AND car_satisfied, 1, 0)) AS car_satisfied
,sum(IF (car_washed AND NOT car_satisfied, 1, 0)) AS car_unsatisfied
,MONTH(r.create_date) AS create_month
,YEAR(r.create_date) AS create_year
FROM t_vss_survey_response r
LEFT JOIN t_vss_dealer d ON (r.dealer_id = d.id)
WHERE survey_code = "ASS"
GROUP BY dealer_code, YEAR(r.create_date), MONTH(r.create_date);
那麼這是用我的查詢IM(很簡單),但我總是得到同樣的錯誤。
選擇a.dealer_name,從v_vss_car_wash一個
現在a.dealer_code ,這是導致該錯誤消息
:org.eclipse.birt.data.engine.odaconsumer.OdaDataException:無法獲取結果集元數據。 org.eclipse.birt.report.data.oda.jdbc.JDBCException:SQL語句不返回ResultSet對象。 SQL錯誤#1:'crmsdbdev.d.dealer_name'不在GROUP BY ; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 'crmsdbdev.d.dealer_name' 是不是在GROUP BY
只需添加'd。 dealer_name *在* GROUP BY *子句中。 「ONLY_FULL_GROUP_BY」可能已打開,這就是爲什麼您需要添加未彙總的* SELECT *子句中的所有列。 –