WITH RECURSIVE `cte` AS (
SELECT
`flow_taskDealRecord`.`id`,
`flow_taskDealRecord`.`flowID_id`,
`flow_taskDealRecord`.`taskID_id`,
`flow_taskDealRecord`.`index`,
`flow_taskDealRecord`.`accountID`,
`flow_taskDealRecord`.`accountIDName`,
`flow_taskDealRecord`.`personFactName`,
`flow_taskDealRecord`.`company`,
`flow_taskDealRecord`.`companyName`,
`flow_taskDealRecord`.`result`,
`flow_taskDealRecord`.`processFlag`,
`flow_taskDealRecord`.`reason`,
`flow_taskDealRecord`.`validFlag`,
`flow_taskDealRecord`.`cTime`,
`flow_taskDealRecord`.`detail`,
ROW_NUMBER() OVER ( PARTITION BY `flow_taskDealRecord`.`taskID_id` ORDER BY `flow_taskDealRecord`.`cTime` DESC ) AS `rw`
FROM
`flow_taskDealRecord`
) SELECT
`cte`.`id`,
`cte`.`flowID_id`,
`cte`.`taskID_id`,
`cte`.`index`,
`cte`.`accountID`,
`cte`.`accountIDName`,
`cte`.`personFactName`,
`cte`.`company`,
`cte`.`companyName`,
`cte`.`result`,
`cte`.`processFlag`,
`cte`.`reason`,
`cte`.`validFlag`,
`cte`.`cTime`,
`cte`.`detail`,
`cte`.`rw` AS `rw`,
`flow_flow`.`id`,
`flow_flow`.`typeID_id`,
`flow_flow`.`name`,
`flow_flow`.`flowDescribe`,
`flow_task`.`id`,
`flow_task`.`taskName`,
`flow_task`.`taskObjID`,
`flow_task`.`taskObjCode`,
`flow_task`.`taskObjName`,
`flow_task`.`taskObjCompanyID`,
`flow_task`.`taskObjCompanyName`,
`flow_task`.`taskObjTeamID`,
`flow_task`.`taskObjTeamName`,
`flow_task`.`flowType_id`,
`flow_task`.`flowID_id`,
`flow_task`.`currentIndex`,
`flow_task`.`resultCallbackURL`,
`flow_task`.`detailCallbackURL`,
`flow_task`.`status`,
`flow_task`.`reason`,
`flow_task`.`cTime`,
`flow_task`.`mTime`,
`flow_task`.`callBackSuccess`
FROM
`cte`
INNER JOIN `flow_flow` ON ( `cte`.`flowID_id` = `flow_flow`.`id` )
INNER JOIN `flow_task` ON ( `cte`.`taskID_id` = `flow_task`.`id` )
WHERE
`cte`.`rw` = 1
ORDER BY
`cte`.`cTime` DESC
i get 18143 when use count() first, i get 17096 when i use len(). and then i get 17096 when using count() second.
i get 17096 when execute sql directly.so why i can get 18143?
so is there some bugs for count() when using django-cte?
environment:
code:
output:
sql
i get 18143 when use count() first, i get 17096 when i use len(). and then i get 17096 when using count() second. i get 17096 when execute sql directly.so why i can get 18143? so is there some bugs for count() when using django-cte?