oracle单行子查询返回多行

selectdistinct*from(selectuserinfo0_.USER_IDasUSER1_34_,userinfo0_.create_timeascreat... select distinct * from ( select userinfo0_.USER_ID as USER1_34_, userinfo0_.create_time as create2_34_, userinfo0_.BOSS_EMAIL as BOSS3_34_,
userinfo0_.EMAIL_CHECKING as EMAIL4_34_, userinfo0_.mobile as mobile34_, userinfo0_.OPER as OPER34_, userinfo0_.REMARKS as REMARKS34_,
userinfo0_.user_city as user8_34_, userinfo0_.user_name as user9_34_, userinfo0_.WEIBO_NAME as WEIBO10_34_ ,
(select count(t.mail_address) from ad_click_detail t, user_info u
where t.mail_address =u.boss_email(+) group by t.mail_address ,u.boss_email) count

from user_info userinfo0_ where 1=1
and userinfo0_.BOSS_EMAIL in ( select u.boss_email from ad_click_detail t, user_info u
where t.mail_address =u.boss_email group by t.mail_address ,u.boss_email )
and
userinfo0_.create_time>=to_date('1999-07-16 00:00:00', 'yyyy-mm-dd hh24:mi:ss') and userinfo0_.create_time<to_date('2014-07-13',
'yyyy-mm-dd hh24:mi:ss') ) order by count

仿照的是这个例子:
select 广告表.*, (select count(1) from 广告点击表 where 广告表.id = 广告点击表.广告ID) 点击次数
from 广告表
order by 点击次数 desc
展开
 我来答
李翀昊
2014-07-17 · 超过53用户采纳过TA的回答
知道小有建树答主
回答量:98
采纳率:0%
帮助的人:98.2万
展开全部
(select count(t.mail_address) from ad_click_detail t, user_info u where t.mail_address =u.boss_email(+) group by t.mail_address ,u.boss_email) count

userinfo0_.BOSS_EMAIL in ( select u.boss_email from ad_click_detail t, user_info u where t.mail_address =u.boss_email group by t.mail_address ,u.boss_email )
将这里面的order by 语句去掉,子查询中好像不能够使用order by语句的,而且order by 在这毫无用处,完全是多余而又浪费资源的一种行为。去掉order by语句
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式