From this table of dates and categories inputs :

[![enter image description here](https://i.stack.imgur.com/8xEeq.png)](https://i.stack.imgur.com/8xEeq.png)

I'd like to get these folowing table, showing number of rows per category for each first and second quarter, and the growth of number of rows between second and first quarter, in value, and in percentage - which is a simple statistic table type that could be met to get the number of item per period of time and its growth.

[![enter image description here](https://i.stack.imgur.com/LMk3c.png)](https://i.stack.imgur.com/LMk3c.png)

What would be the sql query to get this table ?

Here is the SQL code to create the sql table, in order you to reproduce the schema:

```
CREATE TABLE `table_a_test_table` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `date_row` timestamp NULL DEFAULT NULL,
  `category` varchar(255) NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;

```

Here is the sql code to fill the table with the data :

```
INSERT INTO `table_a_test_table` (`date_row`, `category`) 
VALUES 
    ('2020-01-03 00:00:00', 'A'),
    ('2020-02-02 00:00:00', 'A'),
    ('2020-03-08 00:00:00', 'B'),
    ('2020-02-06 00:00:00', 'C'),
    ('2020-04-07 00:00:00', 'B'),
    ('2020-05-21 00:00:00', 'A'),
    ('2020-06-07 00:00:00', 'C'),
    ('2020-06-08 00:00:00', 'B')
;

```

I've tried the following sql code, to get the result table, but I do not know where I should, and how I should introduce the `category` field in order to get a group by output.

```
SELECT 
    nb_rows_q1.nb_of_rows AS `number of row in q1`,
    nb_rows_q2.nb_of_rows AS `number of row in q2`,
    ((nb_rows_q2.nb_of_rows - nb_rows_q1.nb_of_rows)/nb_rows_q1.nb_of_rows)*100 AS `growth nb of rows between q2 vs q1`
FROM 
    (
    SELECT  COUNT(id) AS nb_of_rows
    FROM    table_a_test_table
    WHERE 
        date_row >= '2020-01-01 00:00:00' 
        AND date_row < '2020-04-01 00:00:00'
    ) AS nb_rows_q1,
    (
    SELECT  COUNT(id) AS nb_of_rows
    FROM    table_a_test_table
    WHERE 
            date_row >= '2020-04-01 00:00:00' 
        AND date_row < '2020-07-01 00:00:00'
    ) AS nb_rows_q2 
;

```

The above code, returns the following :

[![enter image description here](https://i.stack.imgur.com/V5JW0.png)](https://i.stack.imgur.com/V5JW0.png)

So now, I'd like t place the `category` field into the code. But I do not knwo how to do it.

Any idea ?