I am using Angular Material Grid which has Server Side Pagination facility and pulling data from the Oracle Database
In this I want to Sort the data for the whole Grid instead of 1st Page on click of the Header of the Grid.
Internally, I using the below Query to fetch paged records from the Database but it failed in Sorting the whole Data and display first 10 records in the Front-End.
What needs to be changed in the below SQL Query to sort the whole Table data and return first 10 records?
string sqlUsers = " WITH SELECTION AS ( " +
" SELECT ROW_NUMBER() OVER(ORDER BY A.USERNAME) RN, A.USERID, A.USERNAME " +
" FROM USER A WHERE A.ROLEID = :roleId) " +
" SELECT " + pageNumber + " PAGE_NUMBER, CEIL((SELECT COUNT(*) FROM SELECTION ) / " + pageSize + ") TOTAL_PAGES, " + pageSize +
" PAGE_SIZE, (SELECT COUNT(*) FROM SELECTION ) TOTAL_ROWS, " +
" SELECTION.* FROM SELECTION " +
" WHERE RN BETWEEN((" + pageSize + "*" + pageNumber + ")- " + pageSize + " + 1) AND (" + pageSize + "*" + pageNumber + ")";
if (string.IsNullOrEmpty(sortDirection) || sortDirection == "asc")
{
sqlUsers = sqlUsers + " ORDER BY USERNAME";
}
else
{
sqlUsers = sqlUsers + " ORDER BY USERNAME DESC ";
}