【发布时间】:2011-07-13 08:20:40
【问题描述】:
WITH abc AS
(
SELECT p_id
, t1.amount as amount
, SUM(amount) OVER (PARTITION BY '|| pqr_rec.p_type ||' ) AS sum_amount
FROM table1 t1, temp_table tt1t
WHERE t1.activity_type = 'pqr_rec.p_activity_type'
)
SELECT p_id
, sum_amount
, amount
FROM abc
WHERE sum_amount > '||pqr_rec.p_amount
t2 表:
xyz_id p_type p_amount p_activity_type
============================================================================
p_1 p_id,date 100000 sell
t1 表:
T_id p_id amount date p_activity_type
=====================================================================
1 E1 100 1984-10-27 00:02:00 sell
2 E1 200 1984-10-27 00:04:00 sell
3 E1 200 1984-10-27 00:05:00 sell
4 E1 300 1984-10-27 00:06:00 sell
5 E1 100 1984-10-27 00:07:00 sell
现在这里的表 t2 第一条记录被游标 pqr 获取并运行上面的查询,所以分区是根据 p_id 和日期完成的,但问题是日期包含时间戳,所以group by 不起作用。我需要根据没有时间戳的日期进行 group by。
我们如何处理这种情况。 我正在使用 ORACLE
【问题讨论】: