Amazon Redshift中的语法错误

时间:2016-03-30 08:51:04

标签: sql amazon-redshift

我有一个语法错误,我现在无法解决一小时:

  

错误:42601:语法错误在或附近")"

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
;

我试图在with闭包内运行select语句,它按预期运行。 我想错误是在select 2198 as customer_site, ...

下的某个地方

我使用MySql逻辑(WITH闭包除外)所以也许我的错误源于此。 任何人吗?

1 个答案:

答案 0 :(得分:0)

我将HTML转换为 public Bitmap mergeBitmap(Bitmap bitmap1, Bitmap bitmap2) { Bitmap mergedBitmap = null; int w, h = 0; h = bitmap1.getHeight() + bitmap2.getHeight(); if (bitmap1.getWidth() > bitmap2.getWidth()) { w = bitmap1.getWidth(); } else { w = bitmap2.getWidth(); } mergedBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mergedBitmap); canvas.drawBitmap(bitmap1, 0f, 0f, null); canvas.drawBitmap(bitmap2, 0f, bitmap1.getHeight(), null); return mergedBitmap; } ,错误从未回来:

IF