Igor Tandetnik wrote:
> Dennis Volodomanov <i...@psunrise.com> wrote:
>   
>> Let's say I've got this query:
>>
>> SELECT * FROM (SELECT * FROM Data WHERE PlotOnGraph=1 ORDER BY Date
>> ASC) LIMIT ?2 OFFSET ?1
>>     
>
> Why an extra layer? Why not just
>
> SELECT * FROM Data WHERE PlotOnGraph=1 ORDER BY Date ASC
> LIMIT ?2 OFFSET ?1
>   

No real reason. I am porting older code and kept it "safe" (keeping old 
SQL unchanged for the time being). I'll change that later.

>> and let's say, "Data" has an "ID" field (primary index).
>>
>> Is it possible to find out the *position* in the returned result set
>> of a Data with a given ID?
>>     
>
> select count(*) from Data
> where PlotOnGraph=1
>     and Date < (select Date from Data where ID=?);
>   

Looks interesting - I'll try it later tonight!

Thank you for the help.

   Dennis

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to