Search code examples
t-sqldataexplorer

Why does T-SQL think a an item is a column name?


Note: I am just starting with SQL/T-SQL and I am not searching for a more elegant solution, just for a fix.

So I'm trying to use the Stack Exchange Data Explorer to count how many times a badge has been awarded. My query goes something like this:

SELECT COUNT(Id)
FROM Badges
WHERE Name = "Scholar"

The results should be the number of times the Badge has been awarded. It, however, returns this error:

Line 3: Invalid column name 'Scholar'.

Solution

  • Replace double quote to single quote

    SELECT COUNT(Id)
    FROM Badges
    WHERE Name = 'Scholar'