Subset 使用SUM的数据库子集

Subset 使用SUM的数据库子集,subset,Subset,我在第二行中遇到了一个错误? 不知道如何纠正 Bob M您应该将整个查询放在一个字符串中 在这里,你似乎并没有引用这个表达: rs = s.executeQuery("SELECT Class1_predicted, Class2_predicted, Class3_predicted, Class_predicted" + SUM(PROFIT_LOSS) AS "Total Profit", + "FROM xxxxxx " + "WHERE CLASS1_PREDICTED = curr

我在第二行中遇到了一个错误? 不知道如何纠正


Bob M

您应该将整个查询放在一个字符串中

在这里,你似乎并没有引用这个表达:

rs = s.executeQuery("SELECT Class1_predicted, Class2_predicted, Class3_predicted, Class_predicted"
+  SUM(PROFIT_LOSS) AS "Total Profit",
+ "FROM xxxxxx "
+ "WHERE CLASS1_PREDICTED = curr_class1_predicted, CLASS2_PREDICTED = curr_class2_predicted, CLASS3_PREDICTED = curr_class3_predicted, CLASS_PREDICTED = curr_class_predicted,"
+ "PROFIT_LOSS >= 0,"
+ "GROUP BY Class1_predicted, Class2_predicted, Class3_predicted,Class_predicted");

rs.next(); 

int recordCount = rs.getInt(1);

myConsole.getOut().println("Number of records in subset of table xxxxx where P/L >= 0: " + recordCount);
应该是这样的:

+  SUM(PROFIT_LOSS) AS "Total Profit",
+  "SUM(PROFIT_LOSS) AS Total_Profit,"