【发布时间】:2014-05-12 04:44:19
【问题描述】:
我想在oracle中加入2个SQL查询,但我真的不熟悉,我的结构对我来说似乎是正确的,但我有这个SQL错误消息:“[Err] ORA-00933: SQL command not正确结束”
所以我有两个疑问: 第一个是:
select
campaign_id, count(*) as "number of emails sent"
from
dg_res_sent
where
dg_end_date > sysdate
group by campaign_id
第二个是:
select
offer_name,
campaign_id,
offer_category as "link category",
count(*) as "number of clicks"
from
dg_res_click
where
dg_end_date > sysdate
and
SUBSTR(offer_name,1,3) = 'SKU'
group by
offer_name,
campaign_id,
offer_category
我想加入campaign_id,所以我做到了:
select
offer_name,
campaign_id,
offer_category as "link category",
count(*) as "number of clicks",
sent.nb_sent
from
dg_res_click
where
dg_end_date > sysdate
and
SUBSTR(offer_name,1,3) = 'SKU'
inner join
(select
campaign_id, count(*) as "nb_sent"
from
dg_res_sent
where
dg_end_date > sysdate
group by campaign_id) sent
on
sent.campaign_id = dg_res_click.campaign_id
group by
offer_name,
campaign_id,
offer_category
知道为什么我会收到此消息:
[Err] ORA-00933: SQL 命令未正确结束
【问题讨论】:
-
内连接不应该放在where子句之前吗?
-
我删除了 MySQL 和 SQL Server 标签,因为这个问题是关于 Oracle 的。