I am using PostgreSQL databse.
I have the tables job, job_application, interview and their structure is as below :
job table:
select * from job;
job_application table
select * from job_application;
interview table:
select * from interview;
I have prepared a query to get some data by joining above tables something like below(of course, my actual requirement is slightly different and that I will explain later):
SELECT job_description,
       i1.interview_type,
       hired,
       open_positions - hired   AS remaining,
       Count(i1.interview_type) AS current_count
FROM   job
       INNER JOIN job_application j1
               ON job.id = j1.job_id
       INNER JOIN interview i1
               ON j1.id = i1.jobapplication_id
GROUP  BY i1.interview_type,
          job_description,
          hired,
          open_positions; 
The above query will result data something like below:

But my actual requirement is to get the count of each interview_type(L1, L2, HR etc...from interview table) against the job_description.
For example something like below:

Can anyone guide/explain me how to get the data in the above format from the query that I have already prepared? Please let me know if you need any information.



 
    