我想在1个语句中运行3个不同的查询。表中是否有NULL值无关紧要。
示例:
(SELECT ticket_state.name AS 'Ticket State',
COUNT(ticket.ticket_state_id) AS 'Number of Active Request'
FROM Ticket
INNER JOIN ticket_state ON ticket.ticket_state_id = ticket_state.id
WHERE (ticket_state_id = 1
OR ticket_state_id = 4
OR ticket_state_id = 10
OR ticket_state_id = 11)
GROUP BY ticket.ticket_state_id);
和
(SELECT
SUM(ticket.queue_id = 12) AS 'Closed at HelpDesk',
COUNT(ticket.id) AS 'Total Closed Ticket',
(SUM(ticket.queue_id = 12) / COUNT(ticket.queue_id) * 100) AS 'Percent Closed at Helpdesk'
FROM ticket
WHERE (ticket_state_id = 3 OR ticket_state_id = 2))
我想在一个表中查询两个查询!