请教一SQL语句

yangsanshao 2003-11-27 01:36:26
有A,B表。A表记录如下
seq account_id account_name balace
1 1001 100
2 1001 200
3 1001 100
4 1002 150
5 1002 100
B表如下:
account_id account_name
1001 现金
1002 银行
请问如何写SQL语句实现下表显示
seq account_id account_name balace
1 1001 现金 100
2 1001 200
3 1001 100
4 1002 银行 150
5 1002 100

...全文
21 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangsanshao 2003-11-27
  • 打赏
  • 举报
回复
谢谢各位
wwl007 2003-11-27
  • 打赏
  • 举报
回复
ruyuezhang(ruyue) ( ) 信誉:100 绝对同意你的观点
ruyuezhang 2003-11-27
  • 打赏
  • 举报
回复
select a.seq,a.account_id,b.account_name,a.balace from a,b
where (a.seq,a.account_id )in (select min(seq) seq,account_id from a group by account_id)
and a.account_id=b.account_id
union
(select seq,account_id,account_name,balace from a
where (seq,account_id) not in (select min(seq) seq,account_id from a
group by a.account_id))
order by seq
xinpingf 2003-11-27
  • 打赏
  • 举报
回复
这个在sqlplus下可以实现

SQL> break on account_name
SQL> select a.seq,a.account_id,b.account_name,balace
from a, b where a.account_id=b.account_id;
whan1234 2003-11-27
  • 打赏
  • 举报
回复
easy.

select a.seq,
a.account_id,
b.account_name,
a.balace
from
a,b
where
a.account_id=b.account_id(+)
;
bzszp 2003-11-27
  • 打赏
  • 举报
回复
select * from a,b where a.account_id=b.account_id(+);

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧