Hi JP,

JP wrote:

Anyway, maybe separate topic, I tried to create a "snapshot" window of the above using plain SQL, but it doesn't seem to work on Sqlite 3.3.4:

CREATE TABLE clients (custid integer primary key, lastname varchar(50));
CREATE INDEX cidx ON (lastname);

(insert 10,000 records here)

SELECT idx,lastname FROM
(
-- get names before search criteria
SELECT '1' as idx,lastname
    FROM (select lastname from customers where lastname<'sprenkle'
    ORDER BY lastname DESC LIMIT 50)
UNION
-- get names matching search criteria plus 50 more
SELECT '2' as idx,lastname
    FROM (select lastname from customers where lastname>='sprenkle'
    ORDER BY lastname ASC LIMIT 50)
)
order by 1,2;

Individually, the queries work fine. In UNION, each seems to lose the inner order clause and show innacurate results.

jp


Instead of "order by 1,2", don't you mean "order by idx"?

Ulrik P.

Reply via email to