Including DISTINCT to an SQL query that also uses ORDER BY CAST(thecolumn AS int) as shown here seems to remove that sorting functionality.
Any reason these cant work together?
(Using sqlite with the C api)
Thanks.
EDIT:
Started with –
sprintf(sql, "SELECT DISTINCT rowX FROM TableX Order By Cast(rowX As int) LIMIT 150 OFFSET %s;", Offset);
rowX is Type CHAR(5)
NOW:
sprintf(sql, "Select rowX FROM(Select Distinct rowX From TableX)t Order By Cast(rowX As int) LIMIT 150 OFFSET %s;", Offset);
I used the following with
sqlite, and sorting worked fine:Have you tried putting the
DISTINCTinto a sub-query?I would expect it to work that way.
One more way: