我在 sqlite 查询结果中的子查询有问题。当执行以下查询成功返回 Sqlite 数据库中的结果但运行程序时它不返回任何值。我在下面的程序中做错了什么。请指教。
询问:
select * from (SELECT count(*), col2,col9,col4 FROM tbl_data_1 WHERE col4=6 AND col3 BETWEEN '2012-11-21' AND '2013-04-19' GROUP BY col2,col9,col4) as inr_qry where col2= '20016' and col9='3'
java中的程序:
Vector<Vector> dataList = new Vector();
for (int i =0; i < listRows.size(); i++){
Vector cols = new Vector();
cols.add(listRows.get(i));
for (int j = 1; j < listColumns.size(); j++){
// below query will be dynamic
String inner_query = "select * from (SELECT count(*), col2,col9,col4 FROM tbl_data_1 WHERE col4=6 AND col3 BETWEEN '2012-11-21' AND '2013-04-19' GROUP BY col2,col9,col4) as inr_qry where col2= '20016' and col9='3'";
PreparedStatement data_st = database.getConnection().prepareStatement(inner_query);
ResultSet data_rs = data_st.executeQuery();
while (data_rs.next()) { // result not successful, result set not having records
SLogger.printD("data_rs.getString(1): " +data_rs.getString(1));
cols.add(data_rs.getString(1));
}
}
dataList.add(cols);
}