def as_sql(self, qn, connection):
        field = qn(self.field)
        deleted_on = qn("deleted_on")
        if self.table is not None:
            table = qn(self.table)
            field = "{0}.{1}".format(table, field)
            deleted_on = "{0}.{1}".format(table, deleted_on)
        return "CASE WHEN {0} IS NULL THEN {1} ELSE NULL END".format(
           deleted_on, field), []
Return CASE statement to select only not-deleted objects.
dataset/ETHPy150Open mozilla/moztrap/moztrap/model/mtmodel.py/NotDeletedCountColumn.as_sql