Run a query on Oracle, 但有ORA-00933 error (SQL command .doesnt end properly)
本人水平有限, 不知如何重写.
SQL 高手请帮忙!!
SELECT
a.member_id,
flag,
sum(a.value_amt) as total_spend
FROM
master.f_purchase_category b,
master.d_date c,
WHERE b.d_trans_date_key=c.d_date_key
and c.cal_dt >= to_date ('2006-01-01','yyyy-mm-dd')
and c.cal_dt < to_date ('2006-03-20','yyyy-mm-dd')
group by a.member_id,
CASE when c.cal_dt >= to_date('2006-01-01','yyyy-mm-dd')
and c.cal_dt < to_date('2006-02-01','yyyy-mm-dd')
THEN '1'
when c.cal_dt >= to_date('2006-02-01','yyyy-mm-dd')
and c.cal_dt < to_date('2006-03-01','yyyy-mm-dd')
THEN '2'
ELSE '3'
end as flag
本人水平有限, 不知如何重写.
SQL 高手请帮忙!!
SELECT
a.member_id,
flag,
sum(a.value_amt) as total_spend
FROM
master.f_purchase_category b,
master.d_date c,
WHERE b.d_trans_date_key=c.d_date_key
and c.cal_dt >= to_date ('2006-01-01','yyyy-mm-dd')
and c.cal_dt < to_date ('2006-03-20','yyyy-mm-dd')
group by a.member_id,
CASE when c.cal_dt >= to_date('2006-01-01','yyyy-mm-dd')
and c.cal_dt < to_date('2006-02-01','yyyy-mm-dd')
THEN '1'
when c.cal_dt >= to_date('2006-02-01','yyyy-mm-dd')
and c.cal_dt < to_date('2006-03-01','yyyy-mm-dd')
THEN '2'
ELSE '3'
end as flag