D. Richard Hipp wrote,
To: <sqlite-users@sqlite.org>
Sent: Thursday, February 15, 2007 3:41 PM
Subject: Re: [sqlite] ORDER BY not providing the expected result
"jose isaias cabrera" <[EMAIL PROTECTED]> wrote:
Greetings!
I have this schema,
CREATE TABLE LSOpenJobs
(
id integer primary key, ProjID, parent, children, login, cust,
proj, PClass, PSubClass, bdate, ddate, edate, pm, pmuk, lang, vendor,
vEmail, invoice, ProjFund, A_No, wDir, notes, status
);
When I do a,
SELECT * FROM LSOpenJobs WHERE status='o' ORDER BY ProjID, PSubClass,
parent, bdate, ddate, edate;
the ORDERing, or sorting, is done alphabetically and not numerically. Is
there a possibility to get this ORDER BY done numberically? ProjID is an
integer, and so I end up with this,
The easiest way to do this is to say "ProjID INTEGER" instead of
just "ProjID" in your CREATE TABLE statement.
Another approach is to say "CAST(ProjId AS INTEGER)" instead of
just "ProjID" in the ORDER BY clause. But this second approach
will silently convert non-integer strings into zero, which might
not be exactly what you want to do with them.
Never even thought about defining it as an integer. The second one would
also work, since there is a function that acts upon ProjID having a value of
0, which will make that scenario safe for the data in db.
thanks,
josé
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------