0

I want to run 3 different queries into 1 statement. It doesn't matter if NULL values are in table.

Example:

(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);

And:

(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))

I want both queries in one table!

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
dHumphrey
  • 307
  • 2
  • 7
  • 24
  • 1
    Queries are not 'in a table' at all. I think you mean to [union](http://dev.mysql.com/doc/refman/5.0/en/union.html) the queries, but since the queries are so different I think you'll need to provide some information about input data and desired output. – GolezTrol Dec 16 '14 at 21:50
  • 1
    Please edit your question and show examples of your desired output. – Gordon Linoff Dec 16 '14 at 22:14
  • maybe this helps (if you use PHP): http://stackoverflow.com/questions/802437/how-to-execute-two-mysql-queries-as-one-in-php-mysql :) – M-A-X Dec 16 '14 at 22:35

0 Answers0