I have a data that should be presented as a flexible table.
For example, this is how I save the data on my mysql server:
Column 1    | Column 2| Column 3| Column 4|Column 6|
------------|---------|---------|---------|--------|
UniqueValue1| value   | value 1 |   aaa   |    1   |
UniqueValue2| value   | value 1 |   bbb   |    2   |
UniqueValue3| value   | value 3 |   ccc   |    3   |
UniqueValue4| value   | value 2 |   ddd   |    4   |
Now, I want to present it on a web site with the ability to query this database. For example
Querying all the data where you find the "value 1" on column 3 and group it by column 3. The result will be

Querying all the data where column 5 is bigger than 2 and group it by column 3 The result will be:

                        
Please find below 2 queries for your questions.