7个回答
展开全部
select a.id,a.u_name,b.td,b.yuan from 表a a,表b b
where a.id=b.id
and (b.id,b.dt) in (select c.id,max(c.dt) from 表b c group by c.id )
大概是这样,还有其他写法,思路差不多
where a.id=b.id
and (b.id,b.dt) in (select c.id,max(c.dt) from 表b c group by c.id )
大概是这样,还有其他写法,思路差不多
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select a.id,a.u_name,xx.dt,xx.yuan
from a left outer join
(
select b.a_id,b.dt,b.yuan from b,
(select a_id,max(dt) dt
from b
) bb where b.a_id = bb.a_id and b.dt = bb.dt
) xx
on a.id = xx.a_id
from a left outer join
(
select b.a_id,b.dt,b.yuan from b,
(select a_id,max(dt) dt
from b
) bb where b.a_id = bb.a_id and b.dt = bb.dt
) xx
on a.id = xx.a_id
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
--对a,b两表做一连接查询
select a.id,a.U_Name,b.DT,b.Yuan from
(select * from A)a,
(select * from B)b
where a.id =b.id(+)
select a.id,a.U_Name,b.DT,b.Yuan from
(select * from A)a,
(select * from B)b
where a.id =b.id(+)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select a,id,a,u_name,max(b.dt),b,yuan
from a,b
where a.id = b.id(+)
group by a,id,a,u_name,b.yuan;
from a,b
where a.id = b.id(+)
group by a,id,a,u_name,b.yuan;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select A.ID,A.U_Name,C.DT,C.Yuan
from a,
(
select ID,DT,Yuan from B
where (ID,DT) in
(
select ID,max(DT) from B group by id
)
) c
where A.ID=C.ID
from a,
(
select ID,DT,Yuan from B
where (ID,DT) in
(
select ID,max(DT) from B group by id
)
) c
where A.ID=C.ID
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询