CREATEVIEW `kafka_json_source_view` AS SELECT TUMBLE_START(time_stamp,INTERVAL'1'MINUTE) AS win_start, category_id, COUNT(1) AS buy_count FROM `kafka_json_source_table` WHERE user_behavior ='buy' GROUPBY TUMBLE(time_stamp,INTERVAL'1'MINUTE),category_id;
4. 统计每分钟 Top3 购买种类
1 2 3 4 5 6 7 8 9 10
INSERTINTO `jdbc_upsert_sink_table` SELECT b.win_start, b.category_id, CAST(b.buy_count ASINT) AS buy_count FROM (SELECT* ,ROW_NUMBER() OVER (PARTITIONBY win_start ORDERBY buy_count DESC) AS rn FROM `kafka_json_source_view` ) b WHERE b.rn <=3;