只选择一半的记录

只选择一半的记录

本文介绍了只选择一半的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何选择 ID 为空的一半记录.我想要一半,因为我将使用该结果集来更新另一个 ID 字段.然后我将使用该 ID 字段的另一个值更新其余部分.

I am trying to figure out how to select half the records where an ID is null. I want half because I am going to use that result set to update another ID field. Then I am going to update the rest with another value for that ID field.

所以基本上我想用一个数字更新一半的 someFieldID 记录,其余的用另一个数字更新,基本上将更新拆分为我想要更新的字段 someFieldID 的两个值.

So essentially I want to update half the records someFieldID with one number and the rest with another number splitting the update basically between two values for someFieldID the field I want to update.

推荐答案

在 oracle 中你可以使用 ROWNUM psuedocolumn.我相信在 sql server 中你可以使用 TOP.示例:

In oracle you can use the ROWNUM psuedocolumn. I believe in sql server you can use TOP.Example:

select TOP 50 PERCENT * from table

这篇关于只选择一半的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:42