Last active
January 27, 2023 10:43
-
-
Save i-e-b/9f4d9a536377d3c73fa6d6fb1ca27146 to your computer and use it in GitHub Desktop.
Revisions
-
i-e-b revised this gist
Jan 27, 2023 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,11 @@ To get page 1 when ordering by `AssetId` SELECT * FROM AssetTable WHERE AssetId_page = 1 ORDER BY AssetId_data; ``` To get "2nd" page when sorting by location in reverse order ``` SELECT * FROM AssetTable WHERE Location_page = (MAX(Location_page)-1) ORDER BY Location_data DESC; ``` ## Example Page size of two to make the example short. Should really be 10 or so. -
i-e-b created this gist
Jan 27, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ ## Idea For cached queries, each column has a matching 'page-column', that gives the page is should be on *if sorted by that column* That way, we can have a single 'paged' data table, but still correctly sort and page by any column. e.g. (using sample data below) To get page 3 when ordering by `Type` ``` SELECT * FROM AssetTable WHERE Type_page = 3 ORDER BY Type_data; ``` To get page 1 when ordering by `AssetId` ``` SELECT * FROM AssetTable WHERE AssetId_page = 1 ORDER BY AssetId_data; ``` ## Example Page size of two to make the example short. Should really be 10 or so. Asset Table  ``` AssetId_data AssetId_page Name_data Name_page Location_data Location_page Type_data Type_page AcquiredDate_data AcquiredDate_page 1 1 Chair 2 London 2 OfficeFurniture 3 2021-01-05 2 2 1 Cabinet 1 London 2 OfficeFurniture 3 2022-06-04 5 3 2 Desk 4 London 3 OfficeFurniture 4 2020-08-11 1 4 2 Computer 3 London 3 IT 2 2021-07-05 3 5 3 Chair 2 Paris 4 OfficeFurniture 5 2022-05-04 4 6 3 Cabinet 1 Paris 4 OfficeFurniture 4 2021-05-05 3 7 4 Desk 4 Paris 5 OfficeFurniture 5 2020-06-08 1 8 4 Computer 3 Paris 5 IT 2 2021-04-04 2 9 5 Server 5 Berlin 1 IT 1 2022-01-05 4 10 5 Server 5 Berlin 1 IT 1 2023-01-11 5 ```