I'm really new to sqlalchemy (as well as sql), so please don't shoot.
I have two queries:
user_logins_count = self.request.db.query(
sa.func.count(UserSession.id)
).filter(
sa.and_(
UserSession.user_id == user_id,
sa.between(UserSession.date_login_session, start_date, end_date)
)
)
and
user_questions_count = self.request.db.query(
sa.func.count(QuestionAnswer.id).label('questions_amount')
).filter(
sa.and_(
QuestionAnswer.user_id == user_id,
sa.between(QuestionAnswer.created, start_date, end_date)
)
)
Is it possible to have a single query instead of this two?