0
我正在處理一些選擇查詢,並得到錯誤的關鍵字找不到預期在我最後的查詢中,我不能找出問題是什麼。錯誤FROM關鍵字找不到預期的地方
ResultSet rs4 = stmt.executeQuery("SELECT COUNT(UnitPrice) AS 'Total'"
+ "FROM"
+ " orderdetails INNER JOIN orders ON orderdetails.OrderID = orders.OrderID"
+ " WHERE customerID = 'LILAS'"
+ "GROUP BY customerid"
+ "HAVING SUM((UnitPrice * Quantity) - (UnitPrice * Quantity * discount)) > "
+ " (SELECT AVG(SUM((UnitPrice * Quantity) - (UnitPrice * Quantity * discount)))"
+ "AS avg('AMOUNT')"
+ "FROM orderdetails"
+" GROUP BY UnitPrice, Quantity, Discount)");
System.out.println("# of Orders for this customer < average order amount for all customers =" + rs4.getString(1));
提示:打印出你的SQL。它看起來並不像你想的那樣。 –
^作爲另一個提示,請確保您檢查的是在所有正確的位置都有空格。 (好吧,也許這是更多的放棄)。 – AdamMc331
提示:使用'StringBuilder'並且不要連接字符串。 – skypjack