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