I'd like to query a table in order to create a summary, as follows:
The data table:
The output should be:
The queries to create the table are here:
CREATE TABLE Example (
Category TEXT,
Monthly TEXT,
Value INTEGER
);
INSERT INTO Example VALUES ("A", "Jan", 45);
INSERT INTO Example VALUES ("B", "Jan", 23);
INSERT INTO Example VALUES ("A", "Feb", 35);
INSERT INTO Example VALUES ("B", "Feb", 54);
INSERT INTO Example VALUES ("A", "Mar", 34);
INSERT INTO Example VALUES ("A", "Apr", 75);
INSERT INTO Example VALUES ("B", "Apr", 4);
INSERT INTO Example VALUES ("A", "May", 8);
I'm stuck on how to accomplish this, I came with the following query, but it is not working as it should.
SELECT
e.Category ,
MAX(e.Monthly) , -- WRONG! need to fix it
e.Monthly ,
MAX(e.Value)
FROM
Example e
GROUP BY
e.Category ;
How should I write this query correctly? I'm using a SQLite3 database.

