Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将SQL查询转换为Django ORM?_Python_Django_Orm_Django Orm - Fatal编程技术网

Python 如何将SQL查询转换为Django ORM?

Python 如何将SQL查询转换为Django ORM?,python,django,orm,django-orm,Python,Django,Orm,Django Orm,这是我想更改为Django ORM的SQL查询,请帮助 你可以。 select 0 'bucket_id', 'Incomplete' as 'name', count(*) 'user_count' from user_smartreq where job_id = {job_id} and pred_perf is null union select 1 'bucket_id', 'Very Poor' as 'name', c

这是我想更改为Django ORM的SQL查询,请帮助

你可以。
        select 0 'bucket_id', 'Incomplete' as 'name', count(*) 'user_count'
        from user_smartreq where job_id = {job_id} and pred_perf is null
        union
        select 1 'bucket_id', 'Very Poor' as 'name', count(*) 'user_count'
        from user_smartreq where job_id = {job_id} and pred_perf between 0 and 1.999
        union
        select 2 'bucket_id', 'Poor'      as 'name', count(*) 'user_count'
        from user_smartreq where job_id = {job_id} and pred_perf between 2 and 2.999
        union
        select 3 'bucket_id', 'OK'        as 'name', count(*) 'user_count'
        from user_smartreq where job_id = {job_id} and pred_perf between 3 and 3.999
        union
        select 4 'bucket_id', 'Good'      as 'name', count(*) 'user_count'
        from user_smartreq where job_id = {job_id} and pred_perf between 4 and 4.599
        union
        select 5 'bucket_id', 'Great'     as 'name', count(*) 'user_count'
        from user_smartreq where job_id = {job_id} and pred_perf between 4.599 and 5