The constraint, obviously, being that "id" and "name" are each candidate keys ...
--- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users [mailto:sqlite-users- >[email protected]] On Behalf Of Simon Davies >Sent: Friday, 27 April, 2018 09:35 >To: SQLite mailing list >Subject: Re: [sqlite] Sqlite query to get the offset of an entry in >the list. > >On 27 April 2018 at 15:51, Hegde, Deepakakumar (D.) ><[email protected]> wrote: >> Hi All, >> >> We have a requirement where in offset of the primary key ID is >needed as per the sorted list. >. >. >. >> 1 AAA >> 3 BBB >> 5 CCC >> 4 WWW >> 2 ZZZ >> >> So position of ID 3 as per the sorted list of the NAME is 2. > >sqlite> create table t( id integer primary key, data text ); >sqlite> insert into t( data ) values('aaa'), ('zzz'), ('bbb'), >('www'), ('ccc'); >sqlite> >sqlite> select count(*)+1 from t where data<(select data from t where >id=3); >2 > >> Thanks and Regards >> Deepak > >Rgds, >Simon >_______________________________________________ >sqlite-users mailing list >[email protected] >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

