Tbl_Student表 | Tbl_Score表
-------------------- ------------------------------------
id student_name id student_id score
21 张三 | 1 21 80
22 李四 | 2 22 93
23 王五 |王五因为缺考,Tbl_Score表中没有王五的成绩。写一个标准SQL语句,查询的结果为:student_name score
张三 80
李四 93
王五 0
-------------------- ------------------------------------
id student_name id student_id score
21 张三 | 1 21 80
22 李四 | 2 22 93
23 王五 |王五因为缺考,Tbl_Score表中没有王五的成绩。写一个标准SQL语句,查询的结果为:student_name score
张三 80
李四 93
王五 0
解决方案 »
- 数据导入导出求助
- 求个时间段的SQL语句(oracle的)
- !!!尊敬的数据库高手请您关注给予指导oralce 和sql server 问题,急急急!!!!
- 在程序中触发触发器,第一次触发器没有执行完,就触发第二次,会怎么样?
- 關於ORACLE的UTL_SMTP的OPEN_DATA和CLOSE_DATA
- 一个奇怪的问题, 修改系统时间后,再用PLSQL developer就无法查询表.
- 可否在视图上用start with 和 connect by 进行树结构查询?
- SQL> connect /as sysdba SQL> connect /as sysdba SQL> grant select on hr.employees to scott;ORA-01031: 权限不足 这怎么可能呢?
- 查询条件失败:[Oracle][ODBC][Ora]Ora-00904:invalid column name
- 请教下oracle满足某个条件就前面记录方法
- 关于表的设计和数据报表的问题。数据生成的报表如下。一起讨论一下该怎样创建表结构。交流经验!!散分
- 如果找出不同元组的个数?要求重复的元组只计数一次。
id student_name
---------------------------
21 张三
22 李四
23 王五Tbl_Score表
id student_id score
---------------------------------------
1 21 80
2 22 93王五因为缺考,Tbl_Score表中没有王五的成绩。写一个标准SQL语句,查询的结果为:student_name score
--------------------------
张三 80
李四 93
王五 0
select a.student_name , nvl(b.score,0)from
Tbl_Student a,
Tbl_Score b
where a.id = b.student_id(+)
select 21 id,'张三' student_name from dual
union all
select 22 id,'李四' student_name from dual
union all
select 23 id,'王五' student_name from dual
),
Tbl_Score as(
select 1 id,21 student_id,80 score from dual
union all
select 2 id,22 student_id,93 score from dual
)
select student_name,nvl(score,0) score from Tbl_Student tt full join Tbl_Score te on tt.id = te.student_id
--用左连接加nvl()判断是否为空函数
SQL> edi
已写入 file afiedt.buf 1 with Tbl_Student as(
2 select 21 id,'张三' student_name from dual
3 union all
4 select 22 id,'李四' student_name from dual
5 union all
6 select 23 id,'王五' student_name from dual
7 ),
8 Tbl_Score as(
9 select 1 id,21 student_id,80 score from dual
10 union all
11 select 2 id,22 student_id,93 score from dual
12 )
13 select student_name,nvl(score,0) score
14* from Tbl_Student a left join Tbl_Score b on a.id=b.student_id
SQL> /STUD SCORE
---- ----------
张三 80
李四 93
王五 0