依靠表格MS访问c#

时间:2016-04-20 04:33:10

标签: ms-access

我有学生记录。如果我在数据库中重复John重复次数超过2次,我如何计算John在数据库中的记录数量?

________________
Name |    Grade
________________

John |    F
Mo   |    A
John |    F

我想知道有多少F的John得到了?我正在用C#

连接这个数据库

2 个答案:

答案 0 :(得分:0)

你在找这个吗?

SELECT count(Grade),Name
FROM YourTable
GROUP BY Name

答案 1 :(得分:0)

您必须对名称成绩进行分组:

class Products(models.Model):
    fullname    = models.CharField(max_length=250, db_index=True)
    code        = models.CharField(max_length=15, db_index=True, null=True)
    authors     = models.CharField(max_length=300, db_index=True, null=True)
    ...
    def __str__(self):
        return self.fullname

class Barcodes(models.Model):
    product     = models.ForeignKey(Products, on_delete=models.CASCADE)
    barcode     = models.CharField(max_length=25, db_index=True, null=True)
    def __str__(self):
        return self.barcode

class Prices(models.Model):
    product     = models.ForeignKey(Products, on_delete=models.CASCADE)
    price       = models.FloatField(default=0)
    shop_id     = models.IntegerField(default=0)
    shop_name   = models.CharField(max_length=50, null=True)
    def __str__(self):
        return self.shop_name