Lets say I have a pivoted sorted dataset like this
ID Col1 Col2 1 a 11 2 b 22 3 c 33 4 d 44 5 e 55
When I make a paging call by returning two records at a time I would get the first two rows.
Lets say I want to return the same data but not pivot the data so my data set looks like
ID Col Val 1 Col1 a 2 Col1 b 3 Col1 c 4 Col1 d 5 Col1 e 1 Col2 11 2 Col2 22 3 Col2 33 4 Col2 44 5 Col2 55
I would like to write an sql statement that would return the same data as in the first example but without pivoting the data first.
Some additional challanges
1) There could be n columns not just two
2) Tt should also support a filter on all the columns. This part I have solved already see below
Filter on pivoted data WHERE Col1 in ('a', 'b', 'c') AND Col2 in ('11', '22') Filter on unpivoted data WHERE (Col = 'Col1' and Val in ('a', 'b', 'c')) or Col != 'Col1') AND (Col = 'Col2' and Val in ('11', '22')) or Col != 'Col2') Both filters return the same results.
The filter part I have figured out already I am stuck on the sorting and paging.