在使用union连接表查询时,query.list()的时候老报空指针,语句如下:
String sql = "(select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '0') union all "+
//当日新增用户
"(select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and (isvalid = '1' or isvalid = '2')) union all "+
//截止当日已退订的用户
" (select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and isvalid = '0') union all "+
//载止当日已订购的用户
"(select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and (isvalid = '1' or isvalid = '2')) union all "+
//当日暂停推送的用户
"(select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '2') union all "+
//截止当日暂停推送的用户
"(select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '2')";
后面把每个语句的括号去掉就没报错了,哎不这道啥原因
修改成
String sql = "select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '0' union all "+
//当日新增用户
"select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and (isvalid = '1' or isvalid = '2') union all "+
//截止当日已退订的用户
" select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and isvalid = '0' union all "+
//载止当日已订购的用户
"select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and (isvalid = '1' or isvalid = '2') union all "+
//当日暂停推送的用户
"select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '2' union all "+
//截止当日暂停推送的用户
"select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and isvalid = '2'";
String sql = "(select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '0') union all "+
//当日新增用户
"(select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and (isvalid = '1' or isvalid = '2')) union all "+
//截止当日已退订的用户
" (select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and isvalid = '0') union all "+
//载止当日已订购的用户
"(select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and (isvalid = '1' or isvalid = '2')) union all "+
//当日暂停推送的用户
"(select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '2') union all "+
//截止当日暂停推送的用户
"(select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '2')";
后面把每个语句的括号去掉就没报错了,哎不这道啥原因
修改成
String sql = "select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '0' union all "+
//当日新增用户
"select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and (isvalid = '1' or isvalid = '2') union all "+
//截止当日已退订的用户
" select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and isvalid = '0' union all "+
//载止当日已订购的用户
"select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and (isvalid = '1' or isvalid = '2') union all "+
//当日暂停推送的用户
"select count(distinct phone) from ts_user where createdate between to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and to_date(?,'yyyy-MM-dd hh24:mi:ss') and isvalid = '2' union all "+
//截止当日暂停推送的用户
"select count(distinct phone) from ts_user where createdate < to_date(?,'yyyy-MM-dd hh24:mi:ss')"+
" and isvalid = '2'";