现在有4张表: 1.sending_email 总的发送列表,总共约1800W左右
2.open_email 打开列表
3.hb_email 硬弹回列表
4.sb_email 软弹回列表四张表的结构相同,都有3列,为email,时间(emaildatetime)和项目名字(programmename),时间为每个email发送/打开/弹回的时间现在要做一张表,总数和发送表相同,为所有的发送过的email作统计,其格式为
email 发送时间 打开时间 硬弹回时间 软弹回时间 项目名称
1234@XXX 2008_1_1 2008_1_2 abcd
1234@XXX 2008_2_1 2008_2_2 abcd
1234@XXX 2008_3_1 2008_3_2 efgh注意:每一行里打开时间'硬弹回时'软弹回时间 只可能有1个值,即打开了就不可能被弹回,被硬弹回就不可能被软弹回
一个email可能在不同项目里出现多次,也可能在一个项目里出现多次自己写了一小段:
select a.email,a.emaildatetime2 send_time,
(case when a.email in (select email from open_email where programmename=a.programmename) then b.emailtime else null end) open_time,
(case when a.email in (select email from hb_email where programmename=a.programmename) then c.emaildatetime2 else null end) hb_time,
(case when a.email in (select email from sb_email where programmename=a.programmename) then d.emaildatetime2 else null end) sb_time,
a.programmename
from sending_email a,open_email b,hb_email c,sb_email d
where
请问后面的四表连接条件应该怎么写呢?高分跪求~~~~
2.open_email 打开列表
3.hb_email 硬弹回列表
4.sb_email 软弹回列表四张表的结构相同,都有3列,为email,时间(emaildatetime)和项目名字(programmename),时间为每个email发送/打开/弹回的时间现在要做一张表,总数和发送表相同,为所有的发送过的email作统计,其格式为
email 发送时间 打开时间 硬弹回时间 软弹回时间 项目名称
1234@XXX 2008_1_1 2008_1_2 abcd
1234@XXX 2008_2_1 2008_2_2 abcd
1234@XXX 2008_3_1 2008_3_2 efgh注意:每一行里打开时间'硬弹回时'软弹回时间 只可能有1个值,即打开了就不可能被弹回,被硬弹回就不可能被软弹回
一个email可能在不同项目里出现多次,也可能在一个项目里出现多次自己写了一小段:
select a.email,a.emaildatetime2 send_time,
(case when a.email in (select email from open_email where programmename=a.programmename) then b.emailtime else null end) open_time,
(case when a.email in (select email from hb_email where programmename=a.programmename) then c.emaildatetime2 else null end) hb_time,
(case when a.email in (select email from sb_email where programmename=a.programmename) then d.emaildatetime2 else null end) sb_time,
a.programmename
from sending_email a,open_email b,hb_email c,sb_email d
where
请问后面的四表连接条件应该怎么写呢?高分跪求~~~~
解决方案 »
- Oracle中有没有类似SQL server中的Char()函数
- 困扰初学者的一个问题。谢谢!有关三表外关联的。
- 新手请教,ORACLE9i的XML数据库设置问题
- 新人求救,包的调用,查了好久都不知道哪错
- 求助,在SQL中访问Qracle数据库的问题!
- 在LINUX上面安装ORACLE, LINUX一定要有XWINDOW 吗?
- ORACLE 新用户权限分配问题,不好意思,初学ORACLE请兄弟们指导!
- 当成功从令一台机器exp后,是否只要把dmp文件拿到自己的机器上导入,还是也要别的文件?
- 关于occi问题
- Oracle 11g(64位)安装失败,显示[INS-20802]Oracle Net Configuration Assistant 失败
- Error while trying to retrieve text for error ORA-12538
- 我一个update问题
,a.emaildatetime AS 发送时间
,b.emaildatetime AS 打开时间
,c.emaildatetime AS 硬弹回时间
,d.emaildatetime AS 软弹回时间
,a.programmename AS 项目名称
FROM sending_email a, open_email b, hb_email c, sb_email d
WHERE a.email = b.email
AND a.email = c.email
AND a.email = c.email
AND a.email = b.email
SELECT a.email AS 邮箱
,a.emaildatetime AS 发送时间
,b.emaildatetime AS 打开时间
,c.emaildatetime AS 硬弹回时间
,d.emaildatetime AS 软弹回时间
,a.programmename AS 项目名称
FROM sending_email a, open_email b, hb_email c, sb_email d
WHERE a.email = b.email
AND a.email = c.email
AND a.email = d.email
=====================
是你要这样显示?
还是你几张表里就是这样设计,只能出现在一张表内?我看下来应该是几张表都有同一e_mail的纪录,所以你的语句不对,楼上的语句不对楼主贴一下表结构,再贴点数据上来,再贴你要的结果,直接帮你写sql
你这样描述不清楚
SELECT A.EMAIL AS 邮箱,
A.EMAILDATETIME AS 发送时间,
B.EMAILDATETIME AS 打开时间,
C.EMAILDATETIME AS 硬弹回时间,
D.EMAILDATETIME AS 软弹回时间,
A.PROGRAMMENAME AS 项目名称
FROM SENDING_EMAIL A, OPEN_EMAIL B, HB_EMAIL C, SB_EMAIL D
WHERE A.EMAIL = B.EMAIL(+)
AND A.EMAIL = C.EMAIL(+)
AND A.EMAIL = D.EMAIL(+)
email programmename time
1 [email protected] Century 2008-2-29 23:44:10
2 [email protected] Century 2008-3-6 3:01:27
3 [email protected] DOds 2008-2-27 16:34:18
4 [email protected] CENT 2008-2-29 15:50:44
5 [email protected] Century 2008-2-29 15:50:44open 的
email programmename time1 [email protected] Century 2008-3-1 22:18:22
2 [email protected] DOds 2008-2-27 16:34:18hb 的1 [email protected] DOds 2008-2-29 8:12:50
2 [email protected] CENT 2008-2-29 15:50:44sb 的1 [email protected] Century 2008-3-7 16:34:18想要的结果 email programmename sendtime
[email protected] Century 2008-2-29 23:44:10
[email protected] Century 2008-3-6 3:01:27
[email protected] DOds 2008-2-27 16:34:18
[email protected] CENT 2008-2-29 15:50:44
[email protected] Century 2008-2-29 15:50:44 opentime hbtime sbtime
2008-3-1 22:18:22
2008-3-7 16:34:18
2008-2-27 16:34:18
2008-2-29 15:50:44
2008-3-2 13:26:11
看你的结构
你sending表里纪录只会出现在open,hb,sb三张表的任意一张中,出现一次
[email protected] || 2008-2-27 16:34:18 ||2007-12-9 23:26:30 ||2007-12-3 11:43:05 ||21Century就是同一条发送记录即有打开时间又有硬弹回时间,要知道如果打开了的话是不可能被硬/软弹回的.