Query must be a SELECT I try to do a select union with order by but it seem like order by can not use union. 

I receive following message


  Query must be a SELECT


This is my code

(SELECT
  `tabsales_action`.responsible as "Responsible:data:200",
  `tabsales_action`.action_type as "Action Type:data:200",  
  count(*) as "Nb:Int:60"
FROM
  `tabsales_action` 
WHERE
  `tabsales_action`.workflow_state = 'To do'
GROUP BY 
  `tabsales_action`.responsible,   
  `tabsales_action`.action_type
ORDER BY 
  `tabsales_action`.responsible )
UNION (SELECT `tabmfi_loan_action`.responsible,
`tabmfi_loan_action`.action_type FROM  `tabmfi_loan_action`
WHERE
  `tabmfi_loan_action`.workflow_state = 'To do'
GROUP BY 
  `tabmfi_loan_action`.responsible,   
  `tabmfi_loan_action`.action_type
ORDER BY 
  `tabmfi_loan_action`.responsible)
UNION (SELECT `tabin_house_credit_action`.responsible,
`tabin_house_credit_action`.action_type FROM `tabin_house_credit_action`
WHERE
  `tabin_house_credit_action`.workflow_state = 'To do'
GROUP BY 
  `tabin_house_credit_action`.responsible,   
  `tabin_house_credit_action`.action_type
ORDER BY 
  `tabin_house_credit_action`.responsible)
UNION (SELECT `tabservices_planning`.responsible,
`tabservices_planning`.action_type FROM `tabservices_planning`
WHERE
  `tabservices_planning`.workflow_state = 'To do'
GROUP BY 
  `tabservices_planning`.responsible,   
  `tabservices_planning`.action_type
ORDER BY 
  `tabservices_planning`.responsible)
UNION (SELECT `accounting_action`.responsible,
`accounting_action`.action_type FROM `accounting_action`
WHERE
  `accounting_action`.workflow_state = 'To do'
GROUP BY 
  `accounting_action`.responsible,   
  `accounting_action`.action_type
ORDER BY 
  `accounting_action`.responsible)


What can I do?
You've got a few issues here. 

When using the UNION or UNION ALL operator, each query must return the same number of columns. The first query in your list has three columns in the SELECT but the queries that come later only have two. You can create a static value for these if you need to, something like this (using the second query as an example);

 SELECT 
`tabmfi_loan_action`.responsible,
`tabmfi_loan_action`.action_type,
'' --Use a zero length string
FROM  `tabmfi_loan_action`


You cannot order your queries that you use with the UNION operator, you'll have to take your ORDER BY statements out. If you do need to order the result then you will have to use your current statement (all of it) as a subquery and ORDER in an outer SELECT. Something like this

SELECT
a.Field1
,a.Field2
FROM
    (
        SELECT Field1, Field2 FROM Table1
        UNION 
        SELECT Field1, Field2 FROM Table2
    ) a
ORDER BY a.Field1


Try fixing these first and see if this resolves your issues.