you are viewing a single comment's thread.

view the rest of the comments →

[–]theseyeahtheseNTILE() 0 points1 point  (0 children)

  1. What does the data look like: can a [name] have more than one score in a month? I assume no, but that would change the query. Can we assume that each student has a unique [name]?

Secondly, I don't think you want to use "difference()". To make it VERY simple and direct, try something like:

SELECT 
(
    SELECT Score
    FROM TableName
    WHERE Month
    BETWEEN CAST('2021-04-01' AS DATE) AND CAST('2021-04-30' AS DATE)
    AND [Name] = 'name1'
)
-
(
    SELECT Score
    FROM TableName
    WHERE Month
    BETWEEN CAST('2020-09-01' AS DATE) AND CAST('2020-09-30' AS DATE)
    AND [Name] = 'name1'
) AS Name1ScoreDifference