SELECT ud.id as userId, ud.organization_id,ud.first_name,ud.last_name,ud.image_url,agentCount,
dealerCount, IFNULL(inventoryCount, 0) inventoryCount
FROM
(
SELECT * FROM jhi_user ju
INNER JOIN
(
SELECT user_id , organization_id FROM employee e
WHERE role_id in
(SELECT id FROM role r WHERE organization_id in
(SELECT id FROM organization o WHERE sales_person_id = 1)
and name = 'NEXCAR_SALES_PERSON' AND (deleted = 0 or deleted is null))
) userOrg ON ju.id = userOrg.user_Id
) ud
LEFT JOIN
(
SELECT sales_person_id,id, count(id) as dealerCount FROM organization o
GROUP BY sales_person_id
) odetails on odetails.sales_person_id = ud.id
LEFT JOIN
(
SELECT o.id , count(o.id) as agentCount FROM employee e
LEFT JOIN organization o on e.organization_id = o.id
WHERE e.user_id = 1 GROUP BY o.id
) edetails ON ud.organization_id = edetails.id
LEFT JOIN
(
SELECT i.organization_id, count(id) as inventoryCount FROM inventory i
)idetails on idetails.organization_id = odetails.id
the above query i have a table called role in that table i have a column 'name' how to select that column in above