私は今、時間解決できない構文エラーがあります。構文エラー
ERROR: 42601: syntax error at or near ")"
with all_comp_prices as
(
SELECT distinct
m2198.to_product_id AS competitor_product_id,
h_comp.when_seen,
h_comp.when_seen/86400 AS day,
h_comp.price
FROM
tbl_productmatch_2198 as m2198
JOIN
(
select * from tbl_producthistory_2414
union select * from tbl_producthistory_2415
-- insert union more competitors here
)
as h_comp
ON h_comp.product_id = m2198.to_product_id
WHERE
h_comp.when_seen >= extract(epoch from (getdate() - INTERVAL '7 DAYS'))
)
select 2198 as customer_site,
TIMESTAMP 'epoch' + lt.day*86400 * INTERVAL '1 second' as date,
sum(if(ap.price is null,1,0)) as no_price_competitors_products_count,
sum(if(ap.price is null,1,0))/1 as ratio_to_total_competitors_products
from
(
select acp.competitor_product, max(acp.when_seen) latest_time, acp.day from
all_comp_prices as acp
group by acp.competitor_product, acp.day
) as lt -- latest times for each product per day
join
(
all_comp_prices as ap -- all prices for all times
)
on lt.latest_time=ap.when_seen and lt.competitor_product=ap.competitor_product
group by lt.day
;
を私は閉鎖して内部のselect文を実行しようと期待どおりに動作しますが。 は私が(WITH
クロージャを除く)のMySQLロジックで行くので、多分私のミスは、その由来
...ミスがselect 2198 as customer_site,
の下のどこかにあると仮定します。 誰でも?
を使用すると、ISOの日付とタイムスタンプを使用することができたときにエポックを扱うのはなぜ?コーディングとデバッグが非常に簡単になります。マニュアルを読むことはまた助けになります... –