title: Flask-SQLAlchemy query for count
body: <p>I'am  using Flask-SQLAlchemy and i use one-to-many relationships. Two models</p>
  
  <pre><code>class Request(db.Model):
  
        id = db.Column(db.Integer, primary_key = True)
        r_time = db.Column(db.DateTime, index = True, default=datetime.utcnow)
        org = db.Column(db.String(120))
        dest = db.Column(db.String(120))
        buyer_id = db.Column(db.Integer, db.ForeignKey('buyer.id'))
        sale_id = db.Column(db.Integer, db.ForeignKey('sale.id'))
        cost = db.Column(db.Integer)
        sr = db.Column(db.Integer)
        profit = db.Column(db.Integer)
  
        def __repr__(self):
            return '&lt;Request {} by {}&gt;'.format(self.org, self.buyer_id)
  
  class Buyer(db.Model):
        id  = db.Column(db.Integer, primary_key = True)
        name = db.Column(db.String(120), unique = True)
        email = db.Column(db.String(120), unique = True)
        requests = db.relationship('Request', backref = 'buyer', lazy='dynamic')
  
        def __repr__(self):
            return '&lt;Buyer {}&gt;'.format(self.name)
  </code></pre>
  
  <p>I need to identify which Buyer has a minimum requests from all 
  of the buyers.</p>
  
  <p>I could do it manually by creating additional lists and put all 
  requests in a lists and search for the list. But I believe there is another simple way to do it via SQLAlchemy query </p>