Model
class fcc_summary(models.Model):
    OCN_Id = models.AutoField( primary_key=True)
    OCN_Date = models.CharField(max_length = 20, blank = True, null = True)
    OCN_OCN_Id = models.CharField(max_length = 25, blank = True, null = 
True)
    OCN_StateCode = models.CharField(max_length = 5, blank = True, null = 
True)
    OCN_CallsAttempted = models.BigIntegerField(max_length = 20, blank = 
True, null = True)
    OCN_Answered =   models.BigIntegerField(max_length = 20, blank = True, 
null = True)
    OCN_Busy = models.BigIntegerField(max_length = 20, blank = True, null = 
True)
    OCN_RingNoAnswer = models.BigIntegerField(max_length = 20, blank = 
True, null = True)
    OCN_UnassignedNo = models.BigIntegerField(max_length = 20, blank = 
True, null = True)
    OCN_CallType = models.IntegerField(max_length = 11, blank = True, null 
= True)
    OCN_IsRural = models.IntegerField(max_length = 11, blank = True, null = 
True)


to convert this queries into django using above models
1)
    SELECT `OCN_OCN_Id`,`OCN_StateCode`,SUM(`OCN_CallsAttempted`) AS 
OCN_CallsAttempted,
    SUM(`OCN_Answered`) AS OCN_Answered,SUM(`OCN_Busy`) AS OCN_Busy,
    SUM(`OCN_RingNoAnswer`) AS OCN_RingNoAnswer,SUM(`OCN_UnassignedNo`) AS 
`OCN_UnassignedNo`,`OCN_CallType`,`OCN_IsRural`
    FROM `fcc_report_fcc_summary` 
    WHERE SUBSTRING(`OCN_Date`,1,7) = vReportDate AND `OCN_IsRural`=1 GROUP 
BY OCN_OCN_Id ,OCN_CallType ,OCN_StateCode

2)
    SELECT 'All','All' ,SUM(`OCN_CallsAttempted`) AS 
OCN_CallsAttempted,SUM(`OCN_Answered`) AS OCN_Answered,
    SUM(`OCN_Busy`) AS OCN_Busy,SUM(`OCN_RingNoAnswer`) AS 
OCN_RingNoAnswer,SUM(`OCN_UnassignedNo`) AS `OCN_UnassignedNo`,
    `OCN_CallType`,`OCN_IsRural`
    FROM `fcc_report_fcc_summary`  WHERE SUBSTRING(`OCN_Date`,1,7) = 
vReportDate AND `OCN_IsRural`=0
    GROUP BY OCN_OCN_Id ,OCN_CallType ,OCN_StateCode ORDER BY OCN_OCN_Id
    

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68df78eb-f620-41b9-8313-7d1129402ecf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to