On 14 Nov 2016, at 7:23am, Mike King <making1...@gmail.com> wrote: > Thanks. In answer to your question a page of results is displayed in a grid > on the screen. The user selects a row. If they then change the sort order I > want to show the page that contains the selected row (and reselect it). > Each row has a unique ID and i need to know the position in the result set > so I can calculate the page.
This can be done but it requires a lot of programming. If the user changes the sort order you then have to do two searches related to the values of the new key in the selected row. Which means that your software needs to be able to look up the screen column they're sorting on and know which table columns that's related to. Assuming a window showing 25 rows at once. Assuming that each row has a 'rowid' value. Assuming that you know the 'rowid' value for the currently selected row. Assuming you know the name of the table column which corresponds to the sort order Look up the selected row and find the value of the sorting table column. Search backwards in that table, sorted on that row, and find the previous 12 rows. Search forwards in that table, sorted on that row, and find the following 12 rows. Display all 25 of those rows. Remember the first value of the first search in case they scroll up. Remember the last value of the second search in case they scroll down. You're not going to do this in a couple of lines of your programming language or a couple of lines of SQL. And it's complicated enough that I might write it as a library rather than writing a custom version which works only for one screen of one program. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users