我写了这个 sql 查询
update temp_calpoints1
set perwet = (select perwet
from process
where processid = temp_calpoints1.processid)
截至目前,它为每个用户更新 10%,如下所示。
orderid processid uid ordervalue perwet
---------------------------------------------------------------------------------
1 1 1 10000 10
1 1 2 10000 10
1 1 3 10000 10
1 2 1 10000 10
1 2 2 10000 10
1 3 1 10000 10
我希望如果超过 1 个用户以相同的顺序参与 1 个进程,它应该平均分配百分比
这意味着它必须像这样插入
orderid processid uid ordervalue perwet
------------------------------------------------------------------------------
1 1 1 10000 3.33
1 1 2 10000 3.33
1 1 3 10000 3.33
1 2 1 10000 5.00
1 2 2 10000 5.00
1 3 1 10000 10.00
任何的想法?
表结构
CREATE TABLE [dbo].[temp_calpoints1](
[orderid] [int] NULL,
[processid] [int] NULL,
[uid] [int] NULL,
[ordervalue] [bigint] NULL,
[perwet] [float] NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[process](
[processid] [float] NULL,
[processdesc] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[perwet] [int] NULL
) ON [PRIMARY]