On 04/17/2014 07:30 AM, Gerald Young wrote:
sum(case when t.ticket_lock_id = 1 then 1 else 0 end) as unlocked
select  q.name queue, sum(case when t.ticket_lock_id = 1 then 1 else 0 end) as unlocked, sum(case when t.ticket_lock_id = 2 then 1 else 0 end) as locked from ticket t left join queue q on q.id=t.queue_id left join ticket_state ts on ts.id = t.ticket_state_id group by q.name order by q.name;

Worked great,
Thanks!

--
Stephen Clark
NetWolves Managed Services, LLC.
Director of Technology
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve.clark@netwolves.com
http://www.netwolves.com