oracle解决多表关联分组查询问题
2014-07-08 15:11
225 查看
做了一个功能需要分组查询,同时查询A表分组查询的ID需要关联B表的数据,本来想两个表关联查询,但是报group by 语法不正确。所以做了以下修改。
select count(*), cindexid,(select vindexcode from comindex where pk_index =cindexid) as vindexcode ,iquesttype
from rqt_examquest
where pk_examquest in
(
select cexamquestid
from rqt_examquest_b2
where cjobtypeid = '1000LSZY123456100001' or cjobtypeid='1001LSZYp3U34Bxgv7V4'
)
group by cindexid , iquesttype having iquesttype = 1 or iquesttype = 2 or iquesttype = 3
order by cindexid
select count(*), cindexid,(select vindexcode from comindex where pk_index =cindexid) as vindexcode ,iquesttype
from rqt_examquest
where pk_examquest in
(
select cexamquestid
from rqt_examquest_b2
where cjobtypeid = '1000LSZY123456100001' or cjobtypeid='1001LSZYp3U34Bxgv7V4'
)
group by cindexid , iquesttype having iquesttype = 1 or iquesttype = 2 or iquesttype = 3
order by cindexid
相关文章推荐
- oracle解决多表关联分组查询问题
- Oracle:sqlplus查询出的中文是乱码问题的解决(转)
- oracle新建用户导入scott的表,解决新用户查询scott表时出现表或视图不存在的问题
- oracle使用LEFT JOIN关联产生的问题在查询结果中使用CASE WHEN 无法判断
- oracle去重查询/删除,distinct多列问题解决方案!
- oracle分页查询数据重复问题的解决
- 【转】解决Oracle分页查询中排序与效率问题
- Oracle:sqlplus查询出的中文是乱码问题的解决
- 使用连接查询解决一对一实体关联查询时的懒加载问题
- 关于oracle树结构查询 展示 分组,查找父节点,查找子节点问题
- oracle查询日期在查询时解决格式问题
- Oracle:sqlplus查询出的中文是乱码问题的解决(转)
- 对于oracle两表关联更新的问题解决办法
- 解决Oracle Sqlplus查询折行、折页的问题
- 解决Oracle执行查询缓慢的问题
- SQLServer访问Oracle查询性能问题解决
- oracle 11g 查询时数据库有值返回空的bug解决(hibernate架构有这个问题)
- oracle分页查询数据重复问题的解决
- Oracle模糊查询之(4.采用全文索引解决模糊查询,给出具体步骤)采用全文索引解决模糊查询速度慢的问题[主文]
- oracle insert中文数据,查询出现乱码问题解决