Why doesn't SQL DISTINCT work with ORDER BY CAST?

Posted by Tommy on Stack Overflow See other posts from Stack Overflow or by Tommy
Published on 2010-03-17T18:24:22Z Indexed on 2010/03/17 19:21 UTC
Read the original article Hit count: 301

Filed under:
|
|

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)

© Stack Overflow or respective owner

Related posts about sql

Related posts about sqlite