Hi! I'm trying to calculate percentages in a GROUP...
# troubleshooting
d
Hi! I'm trying to calculate percentages in a GROUP BY, with something like this:
Copy code
SELECT
  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
OVER
window aggregates in a
SELECT
clause. However, for streaming queries, the
OVER
windows for all aggregates must be identical due to current limitation.
(and I do get an error if trying it) Is there a way to get a similar result given current limitations?