Combining three queries I am having the table structure

id |  name  |   desig    |  age
1  |   John | supervisor |   M/28
2  | Deborah | Manager   |  F/44
3  | Joan   |Area Manager|  M/52


I am trying to get the count of employees by their desig grouped by age .
Here is the query that is working 

SELECT sum(case when desig='Manager' then 1 else 0 end ) AS Manager
     , sum(case when desig='Area Manager' then 1 else 0 end ) AS Amanager
     , sum(case when desig='Superwisor' then 1 else 0 end ) AS SW
FROM employee_details 
WHERE substring_index(age,'/',-1) &lt; 30


So that i can get the count of employees grouped by designation below 30. I need to get similar counts for the age group between 30-40 , 40-50 and above 50 . Should i go for four different SELECT  queries or is there a different ,more performant way to do this .
I've added a few more rows just to check it.

create table employee_details (id int, name text, desig text, age text);

insert into employee_details values
(1, 'John',    'Supervisor',   'M/28'),
(2, 'Deborah', 'Manager',      'F/44'),
(3, 'Joan',    'Area Manager', 'M/52'),
(4, 'Anna',    'Manager',      'F/35'),
(5, 'Rose',    'Area Manager', 'M/55');


Age group can be computed in this way:

(substring_index(age, '/', -1) DIV 10) * 10 as age_group


Then you can GROUP BY desig and age group:

SELECT   desig,
         (substring_index(age, '/', -1) DIV 10) * 10 as age_group,
         count(*) as count_emp
FROM     employee_details
GROUP BY (substring_index(age, '/', -1) DIV 10) * 10, desig
ORDER BY (substring_index(age, '/', -1) DIV 10) * 10, desig;




desig        | age_group | count_emp
:----------- | --------: | --------:
Supervisor   |        20 |         1
Manager      |        30 |         1
Manager      |        40 |         1
Area Manager |        50 |         2



dbfiddle here

For a custom age groups I'd suggest a tally table:

create table age_group (id int, name text, low int, high int);

insert into age_group values
(1, '&lt; 25',   0,  25),
(2, '25-35', 25,  35),
(3, '35-40', 35,  40),
(4, '40-50', 40,  50),
(5, '&gt;= 50', 50, 150);


Then you can CROSS JOIN this table with all possible designations and use an scalar subquery to get count of employees.

SELECT ed.desig,
       ag.name,
       (SELECT COUNT(*)
        FROM   employee_details
        WHERE  substring_index(age, '/', -1) &gt;= ag.low
        AND    substring_index(age, '/', -1) &lt; ag.high
        AND    desig = ed.desig) count_emp
FROM   age_group ag
CROSS JOIN (SELECT DISTINCT desig 
            FROM   employee_details) ed;




desig        | name  | count_emp
:----------- | :---- | --------:
Supervisor   | &lt; 25  |         0
Supervisor   | 25-35 |         1
Supervisor   | 35-40 |         0
Supervisor   | 40-50 |         0
Supervisor   | &gt;= 50 |         0
Manager      | &lt; 25  |         0
Manager      | 25-35 |         0
Manager      | 35-40 |         1
Manager      | 40-50 |         1
Manager      | &gt;= 50 |         0
Area Manager | &lt; 25  |         0
Area Manager | 25-35 |         0
Area Manager | 35-40 |         0
Area Manager | 40-50 |         0
Area Manager | &gt;= 50 |         2



dbfiddle here