Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

370
Views
django: ¿cómo sumar valores de la misma clave?

Quiero sumar el valor de la clave de conteo si los valores de year_taken tienen duplicados, ¿cómo puedo hacer eso?

ingrese la descripción de la imagen aquí

por lo que la salida se vería así

{'año_tomado': '2019-2020', 'recuento': 1}, {'año_tomado': '2021-2022', 'recuento': 3}

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puedes probar esto:

 from django.db.models import IntegerField, OuterRef, Subquery class SQCount(Subquery): output_field = IntegerField() template = f"(SELECT count(*) from (%(subquery)s)) _count)" subquery_count = SQCount(Subject.objects.filter(year_taken=OuterRef("year_taken"))) queryset = Subject.objects.annotate(count=subquery_count).order_by("year_taken").distinct("year_taken").values("year_taken", "count")
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!