Deepyaman Datta
04/13/2023, 12:45 PMSELECT
cc_num,
merchant,
(SUM(amt) OVER w) / (
SUM(amt) OVER (
PARTITION BY cc_num
ORDER BY ts_ltz RANGE BETWEEN INTERVAL '30' MINUTES PRECEDING AND CURRENT ROW
)
)
FROM transaction_amount
WINDOW w AS (
PARTITION BY cc_num, merchant
ORDER BY ts_ltz RANGE BETWEEN INTERVAL '30' MINUTES PRECEDING AND CURRENT ROW
);
(approach similar as https://stackoverflow.com/a/6207658)
If it's not clear, the idea above is to get the breakdown of transaction amounts by merchant for each cc_num.
However, from https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/queries/over-agg/:
You can define multiple(and I do get an error if trying it) Is there a way to get a similar result given current limitations?window aggregates in aOVERclause. However, for streaming queries, theSELECTwindows for all aggregates must be identical due to current limitation.OVER