tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

how to realize count and distinct together?

Open yodew opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context about the feature request here.

yodew avatar Dec 13 '23 07:12 yodew

I want to execute the below sql:

select count(*) from (SELECT DISTINCT `students_id`, `subject_id`, `school_id`
FROM `user_item_score`
WHERE `deleted` = 0
  AND `score_type` = 2
  AND `score_year` = '') a;

so, how to do with the orm? I try it with Concat and Subquery,but failed.

yodew avatar Dec 13 '23 07:12 yodew

Could you please provide your models ?

vlakius avatar Dec 15 '23 08:12 vlakius