I am trying to run a query in Azure Data Studio from a temporary table that I've created. However, in my SELECT
statement, it does not recognize column name(s). The column names in the SELECT
statement (i.e. FirstPlayer, SecondPlayer, Score
) are underlined red and the query comes back as invalid.
Any idea on how to change the syntax to make this run?
IF OBJECT_ID('tempdb.dbo.#GameScores','U') IS NOT NULL
DROP TABLE #GameScores;
GO
CREATE TABLE #GameScores
(
FirstPlayer VARCHAR(10),
SecondPlayer VARCHAR(10),
Score INTEGER
);
GO
INSERT INTO #GameScores
VALUES ('Joe','Ryan', 120),
('Sue', 'Jackie', 200),
('Ryan', 'Sue', 50),
('Ryan', 'Joe', 100);
GO
SELECT DISTINCT
FirstPlayer,
SecondPlayer,
IF(Score = MAX(Score), MAX(Score) + 20, Score) AS Score
FROM
#GameScores
WHERE
SecondPlayer NOT LIKE "JO%"
OR Points <> 100