You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE PROCEDURE `poly_pay_transaction_max_concurrency`()
BEGIN
DECLARE currentDate DATE;
DECLARE endDate DATE;
-- 获取开始和结束日期
SELECT MIN(DATE(create_time)), (MAX(DATE(create_time))- INTERVAL 1 DAY) INTO currentDate, endDate
FROM poly_pay_transaction;
-- 创建临时表用于存储结果
CREATE TABLE IF NOT EXISTS poly_pay_transaction_max_concurrency (
day DATE,
max_concurrency_time INT,
max_concurrency INT
);
-- 循环计算每一天的活跃商户数
WHILE currentDate <= endDate DO
-- 添加条件判断,确保不重复统计已经处理过的日期
IF NOT EXISTS (SELECT 1 FROM poly_pay_transaction_max_concurrency WHERE day = currentDate)
THEN
INSERT INTO poly_pay_transaction_max_concurrency (day,max_concurrency_time, max_concurrency)
SELECT currentDate, DATE_FORMAT(create_time,'%H') '时间节点', COUNT(id) AS count
FROM poly_pay_transaction
WHERE DATE_FORMAT(create_time,'%Y-%m-%d') = currentDate
GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S')
ORDER BY count DESC
LIMIT 1;
END IF;
-- 更新日期
SET currentDate = currentDate + INTERVAL 1 DAY;
END WHILE;
-- 选择结果
SELECT * FROM poly_pay_transaction_max_concurrency;
-- 删除临时表
-- DROP TABLE IF EXISTS poly_pay_transaction_max_concurrency;
END;
报错信息:
CREATE PROCEDURE `poly_pay_transaction_max_concurrency`()
BEGIN
DECLARE currentDate DATE;
DECLARE endDate DATE;
-- 获取开始和结束日期
SELECT MIN(DATE(create_time)), (MAX(DATE(create_time))- INTERVAL 1 DAY) INTO currentDate, endDate
FROM poly_pay_transaction;
-- 创建临时表用于存储结果
CREATE TABLE IF NOT EXISTS poly_pay_transaction_max_concurrency (
day DATE,
max_concurrency_time INT,
max_concurrency INT
);
-- 循环计算每一天的活跃商户数
WHILE currentDate <= endDate DO
-- 添加条件判断,确保不重复统计已经处理过的日期
IF NOT EXISTS (SELECT 1 FROM poly_pay_transaction_max_concurrency WHERE day = currentDate)
THEN
INSERT INTO poly_pay_transaction_max_concurrency (day,max_concurrency_time, max_concurrency)
SELECT currentDate, DATE_FORMAT(create_time,'%H') '时间节点', COUNT(id) AS count
FROM poly_pay_transaction
WHERE DATE_FORMAT(create_time,'%Y-%m-%d') = currentDate
GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S')
ORDER BY count DESC
LIMIT 1
> 0 - com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'IMIT 1', expect END, actual null, pos 1036, line 28, column 14, token EOF
The text was updated successfully, but these errors were encountered:
报错信息:
The text was updated successfully, but these errors were encountered: