我想在oracle中加入2個SQL查詢,但我真的不熟悉它,我的結構似乎對我來說是正確的,但是我有這個SQL錯誤信息: 「[錯誤] ORA-00933:SQL命令不能正確地結束」oracle,查詢加入問題「SQL命令沒有正確結束」
所以我有兩個疑問: 第一個是:
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子句之前放置內連接嗎? – Ehsan
我刪除了MySQL和SQL Server標記,因爲這個問題是關於Oracle的。 –