现在有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
请问后面的四表连接条件应该怎么写呢?高分跪求~~~~
解决方案 »
- ora-12170 tns 连接超时 的问题
- 我的控制文件被rm -rf误删除了,怎么办?
- oracle基础问题!急
- Enterprise Manager使用怪事(各位老大,救命啊!!!!!!)
- 大家有没有遇到:使用BLOB时,出现:(SQLException: ORA-22920: 未锁定含有 LOB 值的行);是什么原因呢?
- oracle中,对一个表T_CMPP_RECEIVE 操作,出现如下错误?谁能解释一下原因???
- 如何把xml中的数据写到oracle数据库中
- sql的问题,怎样写秒级别的sql语句?
- 在VC中使用ADO访问Oracle数据库的时间是多少?
- 求助,在虚拟机中安装oracle12c的时候出现这个问题怎么解决?
- 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就是同一条发送记录即有打开时间又有硬弹回时间,要知道如果打开了的话是不可能被硬/软弹回的.