There is no exact group by clause and we can use the function annotate to get the count of records with grouping data.

   If we need to fetch the related data from 2 tables,
    first we need to fetch the unique data from first table
    then we can use the filter function with id__in

  ex:    
    mapdata = MedicationMapping.objects.all()
    meds = Medication.objects.filter(id__in=mapdata)