现有table_for_report_1和table_for_report_2,详情如下:
table_for_report_1有num字段,c1,c2,c3字段。
数据如下:
num c1 c2 c3
1 15001346690 11 12 13
2 13329921100 21 22 23
3 18900000000 31 32 33
4 13811111111 41 42 43
table_for_report_2有num字段,c4,c5字段。
数据如下:
num c4 c5
1 13822222222 34 35
2 15001346690 14 15
3 13811111111 24 25
内连接:
select t1.num,t1.c1,t1.c2,t1.c3,t2.c4,t2.c5
from table_for_report_1 t1, table_for_report_2 t2
where t1.num=t2.num
结果:
num c1 c2 c3 c4 c5
1 15001346690 11 12 13 14 15
2 13811111111 41 42 43 24 25
外连接(左外连接和右外连接):
1)左外连接:
select t1.num,t1.c1,t1.c2,t1.c3,t2.c4,t2.c5
from table_for_report_1 t1, table_for_report_2 t2
where t1.num=t2.num(+)
或者
select t1.num,t1.c1,t1.c2,t1.c3,t2.c4,t2.c5
from table_for_report_1 t1 left outer join table_for_report_2 t2
on (t1.num=t2.num)
结果:
num c1 c2 c3 c4 c5
1 15001346690 11 12 13 14 15
2 13811111111 41 42 43 24 25
3 18900000000 31 32 33
4 13329921100 21 22 23
2)右外连接:
select t2.num,t1.c1,t1.c2,t1.c3,t2.c4,t2.c5
from table_for_report_1 t1, table_for_report_2 t2
where t1.num(+)=t2.num
或者
select t2.num,t1.c1,t1.c2,t1.c3,t2.c4,t2.c5
from table_for_rep
一般地,日期格式说明符是不太敏感的。然而,当为了显示而说明日期格式、对于文本数据中的说明符等情况下,它就变得比较务实、具体了。以月份的名字为例,通过下面引用的结果解释一下该情况的效果:
TO_CHAR(SYSDATE,’MONTH’)=NOVEMBER
TO_CHAR(SYSDATE,’Month’)=November
TO_CHAR(SYSDATE,&rsq ......