我有一个问题,如果你能提供帮助,我将不胜感激。
在下图中,我想建立一个名为:最近分数的新列,如您所见,最近分数是用户上次获得的分数。如果我们按日期对行进行排序,则最近的得分是下一行的得分值。
我写了以下代码,但它是错误的:(
SELECT [user-name],
[submissions],
[date],
[score]
(SELECT [score]
FROM [top-concept6] tc6
WHERE tc6.[user-name]=[top-concept6].[user-name]
AND tc6.[date]= (SELECT TOP(1) [date]
FROM [top-concept6] tcc6
WHERE [date]<[top-concept6].[date] ORDER BY [date] DESC)) AS [recent-score]
FROM [top-concept6]
这是 sql 小提琴:http ://sqlfiddle.com/#!3/74e3f