Let's say I have any one of the following expression:
SELECT
DATE '2014-01-01' < '2014-02-01',
DATE '2014-01-01' < '321',
9 < '10',
9 < 'a'
Is there a recommendation or requirement in the SQL standard of how these should be compared? I suppose the three levels or 'strictness' would be the following:
- Raise an error [most strict] -- all 4 expressions above would fail.
- Try casting the string to the non-string type, if it doesn't work raise an error -- expressions 2 and 4 above would fail.
- Try casting the string to the non-string type, if it fails fallback to casting the non-string to a string -- all 4 above work.
- Cast the non-string operand to a string -- all 4 above work.
It seems BigQuery uses the second approach, postgres uses something like 2/3 (only the last one fails), mysql uses either 3 or 4 (no fail).
Does the standard make any recommendations here?