STANDARD SQL DATA TYPE COMPARISON

Viewed 32

Question regarding Standard SQL data type comparisons.

Given the following

SELECT *
FROM album
WHERE LENGTH(title) < 4

Returns 4 rows whose title lengths are less than 4.

On the other hand...

SELECT *
FROM album
WHERE LENGTH(title) < '4' 

Returns all the rows irrespective of the title length. Now, when I check LENGTH(title) < 4, it returns true.

Why would an integer be less than a string... ALWAYS?

The Standard SQL tool being used is both the SQL that can be found in w3school.com and Google's BigQuery. I also noticed that the same would be try for Python.

0 Answers
Related