gpt4 book ai didi

mysql - 将 UPDATE 语句转换为 SELECT 语句

转载 作者:行者123 更新时间:2023-11-29 07:06:09 24 4
gpt4 key购买 nike

以下语句更新名为“test”的表中的列。

UPDATE test AS t
INNER JOIN test AS q ON(
q.ptime = t.ptime
)
SET t.slope_Percentile =(
(
SELECT
count(*)
FROM
(
SELECT
*
FROM
test
)AS t1
WHERE
t1.slope < t.slope
)* 100 /(
SELECT
count(*)
FROM
(
SELECT
*
FROM
test
) AS tz
)
);

我不想更新列,而是希望收到一个 SELECT 语句,该语句提供每行的读数(如果它是 UPDATE 语句,则会更新)。

有关表的性质和代码目标的更多信息(如果需要)在此处: Efficient assignment of percentile/rank in MYSQL

最佳答案

SELECT t.ptime,
(
(
SELECT
count(*)
FROM
(
SELECT
*
FROM
test
)AS t1
WHERE
t1.slope < t.slope
)* 100 /(
SELECT
count(*)
FROM
(
SELECT
*
FROM
test
) AS tz
)
) AS slope_Percentile
FROM test AS t
--INNER JOIN test AS q ON
--q.ptime = t.ptime

关于mysql - 将 UPDATE 语句转换为 SELECT 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7157646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com