Re: Combining two subquery counts using ORM

2022-11-09 Thread Ross Meredith
Last time I checked you can't use subquery inside the FROM clause. If you can please let me know how because I had this a while back and got stuck. I ended up using a package called django-cte. On Wed, Nov 9, 2022 at 9:01 PM Matthew Hegarty wrote: > Thanks > > I made some progress, and this get

Re: Combining two subquery counts using ORM

2022-11-09 Thread Matthew Hegarty
Thanks I made some progress, and this gets me most of the way there (only the total count is wrong at present) def get_queryset(self): created_q = Q(created__gte=self.start_date) & Q(created__lt=self.end_date) completed_q = Q(completed__gte=self.start_date) & Q(completed__l

Re: Combining two subquery counts using ORM

2022-11-09 Thread kateregga julius
Post your model here and we do it On Wed, Nov 9, 2022, 7:37 PM Matthew Hegarty wrote: > My question is about translating a SQL query to the ORM. > > I want to combine the output of two queries into one. The query is > counting records in the same table (Task) using two different fields. > > The