sql 如何嵌套查询
能不能把下面的2条语句合并成一条selectusername,count(username)asnumafromawhereisdel=0groupbyusernameo...
能不能把 下面的2条语句合并成一条
select username,count(username) as numa from a where isdel=0 group by username order by numa desc
select username,count(username) as numb from a where isdel=0 and isx=1 group by username
能不能将上面的两条语句 联合起来输出 username,numa,numb
拜托 看清楚问题好吗?~!~!~!~! 展开
select username,count(username) as numa from a where isdel=0 group by username order by numa desc
select username,count(username) as numb from a where isdel=0 and isx=1 group by username
能不能将上面的两条语句 联合起来输出 username,numa,numb
拜托 看清楚问题好吗?~!~!~!~! 展开
5个回答
展开全部
select a.username,numa,numb
from (select username,count(username) as numa from a where isdel=0 group by username order by numa desc) a,
(select username,count(username) as numb from a where isdel=0 and isx=1 group by username) b
where a.username = b.username
from (select username,count(username) as numa from a where isdel=0 group by username order by numa desc) a,
(select username,count(username) as numb from a where isdel=0 and isx=1 group by username) b
where a.username = b.username
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
java里面要实现sql嵌套查询的话,如果是javaweb项目,是可以使用hibernate框架提供的直接执行sql语句的方式来实现这样的功能.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select username,count(username) as numa from a where isdel=0 group by username order by numa desc
union
select username,count(username) as numb from a where isdel=0 and isx=1 group by username
union
select username,count(username) as numb from a where isdel=0 and isx=1 group by username
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select id,name,department表.department_name from user ,department表 where department_id = department表.id
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select username,count(username)over(partition by username order by numa desc)
from a
where isdel=0 and isx=1
不知是不是这个意思?
from a
where isdel=0 and isx=1
不知是不是这个意思?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |