gpt4 book ai didi

sql - 如何只更新一定比例的匹配值

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

我有一个表,除其他外,还包含以下字段:id 整数、status_id 整数、add_date 日期

我想执行类似这样的查询:

更新表集 status_id = new_status_id where status_id = old_status_id

但是它只会更新给定百分比的值,比如 50%。此外,每个日期更新行的分布应该是相似的;我想要更新 date = 23.06.2013 的一半行,一半不更新。

最佳答案

update table
set status_id = new_status_id
where
status_id = old_status_id
and random() < 0.5

关于sql - 如何只更新一定比例的匹配值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17223612/

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