Re: [sqlite] sqlite puzzle

2006-05-04 Thread JP
Thanks all. Actually I was just looking for the position of a single name. Based on your feedback, this one works to get the results: SELECT count(*) FROM clients WHERE name<'foo'; but its performance is directly proportional to the position of the name in the table. For example, searching

Re: [sqlite] sqlite puzzle

2006-05-02 Thread A. Pagaltzis
And to correct myself one last time: * A. Pagaltzis <[EMAIL PROTECTED]> [2006-05-03 00:30]: > Assuming your client names are unique, this should work: > > SELECT > ( > SELECT > COUNT(*) > FROM clients c2 > WHERE c2.name < c1.name >

Re: [sqlite] sqlite puzzle

2006-05-02 Thread A. Pagaltzis
* A. Pagaltzis <[EMAIL PROTECTED]> [2006-05-03 00:30]: > I tried to do it with a join to see if that would work better, > but I’m too frazzled to figure it out right now. I must be more frazzled than I thought. SELECT n1.name, COUNT( n2.name ) rank FROM names n1 CROSS

Re: [sqlite] sqlite puzzle

2006-05-02 Thread A. Pagaltzis
* JP <[EMAIL PROTECTED]> [2006-05-02 22:10]: > SQLite provides a way to get the N-th row given a SQL statement, with > LIMIT 1 and OFFSET . > > Can the reverse be done in an efficient way? For example, given a table > with 1million names, how can I return the row number for a particular > elem

Re: [sqlite] sqlite puzzle

2006-05-02 Thread A. Pagaltzis
* Kurt Welgehausen <[EMAIL PROTECTED]> [2006-05-02 22:15]: > No, you can't do that in SQL. You can. > The results of an SQL query are a set of rows; the rows are not > produced in any guaranteed order. If this was true, how would `LIMIT` work? Sure, the results do not have any implicit order, b

Re: [sqlite] sqlite puzzle

2006-05-02 Thread Jay Sprenkle
On 5/2/06, JP <[EMAIL PROTECTED]> wrote: Can the reverse be done in an efficient way? For example, given a table with 1million names, how can I return the row number for a particular element? i.e. something like is select rowid from table where name = 'foo' what you want?

Re: [sqlite] sqlite puzzle

2006-05-02 Thread Kurt Welgehausen
JP <[EMAIL PROTECTED]> wrote: > SQLite provides a way to get the N-th row given a SQL statement, with > LIMIT 1 and OFFSET . > > Can the reverse be done in an efficient way? For example, given a table > with 1million names, how can I return the row number for a particular > element? No, you c

[sqlite] sqlite puzzle

2006-05-02 Thread JP
SQLite provides a way to get the N-th row given a SQL statement, with LIMIT 1 and OFFSET . Can the reverse be done in an efficient way? For example, given a table with 1million names, how can I return the row number for a particular element? i.e. something like SELECT rownum FROM