How to get Grafana to show query result in stacked bar chart

Problem: Can’t get Grafana to show query result in stacked bar chart:
MySQL query is like:

SELECT 
  projectName,
  sum(case when buildResult = 'SUCCESS' then 1 else 0 end) AS SuccessCount,
  sum(case when buildResult = 'FAILURE' then 1 else 0 end) AS FailureCount,
  sum(case when buildResult = 'ABORTED' then 1 else 0 end) AS AbortedCount,
  sum(case when buildResult = 'UNSTABLE' then 1 else 0 end) AS UnstableCount
FROM
  executor_data
WHERE
  executorNode = 'ABCD'
GROUP BY projectName

and MySQL Returns:

+--------------------------------+--------------+--------------+--------------+---------------+
| projectName                    | SuccessCount | FailureCount | AbortedCount | UnstableCount |
+--------------------------------+--------------+--------------+--------------+---------------+
| End User A                     |           87 |           53 |            9 |             0 |
| EUA                            |          282 |          139 |            2 |             3 |
| SP                             |           12 |            3 |            0 |             0 |
| NULL                           |            0 |            0 |            0 |             0 |
| FIT                            |            4 |            0 |            0 |             0 |
+--------------------------------+--------------+--------------+--------------+---------------+
5 rows in set (0.00 sec)

I modified my query for Grafana like the following:

SELECT 
  $__timeGroupAlias(time_stamp,$__interval),
  projectName as metric,
  sum(case when buildResult = 'SUCCESS' then 1 else 0 end) AS SuccessCount,
  sum(case when buildResult = 'FAILURE' then 1 else 0 end) AS FailureCount,
  sum(case when buildResult = 'ABORTED' then 1 else 0 end) AS AbortedCount,
  sum(case when buildResult = 'UNSTABLE' then 1 else 0 end) AS UnstableCount
FROM
  executor_data
WHERE
  $__timeFilter(time_stamp) AND executorNode = '$executorNode'
GROUP BY metric, time_stamp
ORDER BY $__timeGroup(time_stamp,$__interval)

What I need:
I need Grafana to show a bar on Grafana for each of the projects consisting of counts on Success/Failure/Aborted/Unstable.

Grafana Would return the following Graph, But it is not stacked and grouped by project names.


I would appreciate if someone could help me out here, and let me know what is it that I am doing wrong!