Facing issue while creating Workflow

Facing issue while creating Workflow
I have created Doctype with submitable true then only i am facing this issue .

traceback.print_stack()
18:07:11 web.1 | Error in query:
18:07:11 web.1 | function max(smallint, tabdemoapp) does not exist
18:07:11 web.1 | LINE 1: select “workflow_state”, count(*) as count, MAX(docstatus, t…
18:07:11 web.1 | ^
18:07:11 web.1 | HINT: No function matches the given name and argument types. You might need to add explicit type casts.

This Query gives error in apps/frappe/frappe/model/db_query.py", line 236, in build_and_run
below are some console i have printed
args.order_by^^^^^^^^^^^^ order by tabdemoapp.docstatus asc, tabdemoapp.modified DESC
18:07:11 web.1 | order_field>>>>>>>>>>>>>>> tabdemoapp.docstatus, tabdemoapp.modified
18:07:11 web.1 | args.fields>>>>>>>>>>>>>>> workflow_state, count() as count
18:07:11 web.1 | extracted_column>>>>>>>>>>>>>>> tabdemoapp.docstatus, tabdemoapp.modified
18:07:11 web.1 | args&&&&&&&&&&&&&&&&&&&&&&&&&& {‘tables’: ‘tabdemoapp’, ‘conditions’: “where ifnull(tabdemoapp.workflow_state, ‘’) not in (‘review’, ‘Pending’, ‘submit’, ‘Rejected’)”, ‘fields’: 'workflow_state, count(
) as count, MAX(docstatus, tabdemoapp) as tabdemoapp.docstatus, tabdemoapp.modified’, ‘order_by’: ’ order by tabdemoapp.docstatus asc, tabdemoapp.modified DESC’, ‘group_by’: ’ group by workflow_state’, ‘limit’: ‘’}
18:07:11 web.1 | Query&&&&&&&&&&&&&&&&&&&&&&&&&& select workflow_state, count(*) as count, MAX(docstatus, tabdemoapp) as tabdemoapp.docstatus, tabdemoapp.modified
18:07:11 web.1 | from tabdemoapp
18:07:11 web.1 | where ifnull(tabdemoapp.workflow_state, ‘’) not in (‘review’, ‘Pending’, ‘submit’, ‘Rejected’)
18:07:11 web.1 | group by workflow_state
18:07:11 web.1 | order by tabdemoapp.docstatus asc, tabdemoapp.modified DESC
18:07:11 web.1 |

select workflow_state, count(*) as count, MAX(docstatus, tableadapp) as tableadapp.docstatus, tableadapp.modified
from tableadapp
where ifnull(tableadapp.workflow_state, ‘’) not in (‘Approved’, ‘Pending’, ‘start app’)
group by workflow_state
order by tableadapp.docstatus asc, tableadapp.modified DESC