STANDARD SQL DATA TYPE COMPARISON

Issue

This Content is from Stack Overflow. Question asked by brking

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.



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?