You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we want to get the year that the concert is on, we have to use SelectRaw. We could have it a a builtin feature instead, with an API like this:
# Get the years in which the band has had concerts>>>awaitConcert.select(Concert.starts.year).where(Concert.band.name=='Pythonistas').distinct().output(as_list=True)
[2022, 2023]
It will be most useful if we can make it work with where clauses:
# Get all concerts in certain yearsawaitConcert.select().where(
Concert.starts.year.is_in([2007, 2009, 2023])
)
And group by:
# Get the number of concerts in each yearawaitConcert.select(
Concert.starts.year,
Count()
).group_by(Concert.starts.year).order_by(Concert.starts.year)
The text was updated successfully, but these errors were encountered:
If we have this table:
If we want to get the year that the concert is on, we have to use
SelectRaw
. We could have it a a builtin feature instead, with an API like this:It will be most useful if we can make it work with where clauses:
And group by:
The text was updated successfully, but these errors were encountered: