I have a table:
create table foo(bar text,baz text);
I want to produce a list of all bar's paired with the longest baz they
are ever associated with. I came up with the following query:
select distinct bar,baz as z from foo where bar in (select bar from foo
where baz==z order by length(bar) desc limit 1);
This query works (although it might not be the best way to do this),
except in the case where bar is a string that can be interpreted as a
number in which case that value of bar never appears in the output.
I assume that in one part of the query it is being treated as a number
and at another as a string, such that they compare not-equal.
Shouldn't the "text" in the table definition cause promotion to string
in every case?
My question is how do i cast bar back to a string, or otherwise cause
sqlite to do the right thing in this case? Or alternatively is there a
different query which would avoid this problem?
Thanks - Chris
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------