Sql e、 最低可能组四分位数
因此,SJ003、MH002等都将与CH001匹配,并用CH001的Sql e、 最低可能组四分位数,sql,sql-server,recursion,Sql,Sql Server,Recursion,因此,SJ003、MH002等都将与CH001匹配,并用CH001的组四分位数值更新,即2 很难解释代码!另一个可能有用的方法是在不使用update语句的情况下查看联接: select a.* , TopCustomer_id = topq.Customer_Id , NewGroup_Quartile = topq.Group_Quartile from activityScores a outer apply ( select top 1 * from act
组四分位数值更新,即2
很难解释代码!另一个可能有用的方法是在不使用update语句的情况下查看联接:
select a.*
, TopCustomer_id = topq.Customer_Id
, NewGroup_Quartile = topq.Group_Quartile
from activityScores a
outer apply
(
select top 1 *
from activityScores topq
where a.Product = topq.Product
and a.Activity_Score = topq.Activity_Score
order by Group_Quartile
) topq
.这是什么RDBMS?SQL Server?还请发布一些失败尝试的实际代码。我已在原始文章中插入了代码。这是什么RDBMS?SQL Server?还请发布一些失败尝试的实际代码。我已在原始文章中插入了这些代码。你好,伊恩,很好的解决方案。它起作用了。你能解释一下它是如何工作的吗?我补充了一些细节;希望他们能帮忙!事实证明,解释代码比编写代码更难。如果我能在这里澄清什么,请告诉我。嘿,伊恩,你的解释很有帮助,但老实说,在你发送解释和理解逻辑之前,我花了一些时间阅读了代码。你是对的,解释代码很难:)嗨,伊恩,很好的解决方案。它起作用了。你能解释一下它是如何工作的吗?我补充了一些细节;希望他们能帮忙!事实证明,解释代码比编写代码更难。如果我能在这里澄清什么,请告诉我。嘿,伊恩,你的解释很有帮助,但老实说,在你发送解释和理解逻辑之前,我花了一些时间阅读了代码。您是对的,解释代码很难:)
CX001 T 0 3
CX001 T 0 2
CX001 T 0 3
KH001 T 0 3
MH002 T 0 4
SJ003 T 0 4
update a
set Group_Quartile = coalesce(topq.Group_Quartile, a.Group_Quartile)
from activityScores a
outer apply
(
select top 1 Group_Quartile
from activityScores topq
where a.Product = topq.Product
and a.Activity_Score = topq.Activity_Score
order by Group_Quartile
) topq
select a.*
, TopCustomer_id = topq.Customer_Id
, NewGroup_Quartile = topq.Group_Quartile
from activityScores a
outer apply
(
select top 1 *
from activityScores topq
where a.Product = topq.Product
and a.Activity_Score = topq.Activity_Score
order by Group_Quartile
) topq