java代码中两个方法,分别调用的两个sql查询的,但为啥一个方法在前执行的结果反在后(下面为查询慢的)
SELECToot.channelProduct,oot.productName,oot.channelCode,oot.channelName,oot.orderSta...
SELECT
oot.channelProduct,
oot.productName,
oot.channelCode,
oot.channelName,
oot.orderStatus,
COUNT(rank) AS num,
MAX(oot.createTime) AS createTime
FROM
(SELECT
a.channelProduct,
a.productName,
a.channelCode,
a.channelName,
a.orderStatus,
a.createTime,
IF(
@pdept = a.concatCode,
@rank := @rank,
@rank := @rank + 1
) AS rank,
@pdept := a.concatCode AS concatCode
FROM
(SELECT
oot.`channel_product` AS channelProduct,
oot.`product_name` AS productName,
oot.`channel_code` AS channelCode,
oot.`channel_name` AS channelName,
oot.`order_status` AS orderStatus,
oot.`create_time` AS createTime,
CONCAT(
oot.`channel_product`,
",",
oot.`channel_code`,
",",
oot.order_status
) AS concatCode
FROM
od_or_table oot
WHERE 1 = 1
ORDER BY oot.`channel_product`,
oot.`channel_code`,oot.`create_time` ) a,
(SELECT
@rank := 0) b) oot
WHERE 1 = 1
AND oot.orderStatus = "FAILED"
GROUP BY oot.rank
HAVING COUNT(rank) >10 展开
oot.channelProduct,
oot.productName,
oot.channelCode,
oot.channelName,
oot.orderStatus,
COUNT(rank) AS num,
MAX(oot.createTime) AS createTime
FROM
(SELECT
a.channelProduct,
a.productName,
a.channelCode,
a.channelName,
a.orderStatus,
a.createTime,
IF(
@pdept = a.concatCode,
@rank := @rank,
@rank := @rank + 1
) AS rank,
@pdept := a.concatCode AS concatCode
FROM
(SELECT
oot.`channel_product` AS channelProduct,
oot.`product_name` AS productName,
oot.`channel_code` AS channelCode,
oot.`channel_name` AS channelName,
oot.`order_status` AS orderStatus,
oot.`create_time` AS createTime,
CONCAT(
oot.`channel_product`,
",",
oot.`channel_code`,
",",
oot.order_status
) AS concatCode
FROM
od_or_table oot
WHERE 1 = 1
ORDER BY oot.`channel_product`,
oot.`channel_code`,oot.`create_time` ) a,
(SELECT
@rank := 0) b) oot
WHERE 1 = 1
AND oot.orderStatus = "FAILED"
GROUP BY oot.rank
HAVING COUNT(rank) >10 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询