Chinaunix

标题: 求一简单的SQL查询语句 [打印本页]

作者: cooljia    时间: 2010-03-22 20:13
标题: 求一简单的SQL查询语句
-- 人员信息表
create table tmpperson(
name varchar2(32),
id number);

-- 初始化steve, smith
insert into tmpperson values('steve', 1);
insert into tmpperson values('smith', 2);

-- 财富表
create table tmpfortune (
id number,
name varchar2(32),
personid number
);

-- steve的编号1,有房子和储蓄
insert into tmpfortune values(1, 'house', 1);
insert into tmpfortune values(2, 'saving', 1);

-- smith的编号2,只有储蓄
insert into tmpfortune values(3, 'saving', 2);

-- 财产详细情况
create table tmpfordetail(
id number,
value number);

-- steve有一栋房子,5w存款
insert into tmpfordetail values(1, 1);
insert into tmpfordetail values(2, 50000);
-- smith有没有房子,1w存款
insert into tmpfordetail values(3, 10000);

求一个查询语句显示以下的查询结果
      Name Fortun Value
        Steve  house  1
        Steve  Saving 50000
        Smith  house  0
        Smith  Saving  10000

先谢谢啦




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2