I have the following query and I need to add it the func.count().over().label('full_count') like described by sayap in this post, but i absolutely don't know how :(.
Here is my query :
paginated_sql_query = "SELECT *, count(*) OVER() AS full_count FROM sim_cards " + sql_query
if per_page > 0:
paginated_sql_query = paginated_sql_query + " LIMIT :limit OFFSET :offset"
parameters["limit"] = per_page
parameters["offset"] = (page - 1) * per_page
result_rows = session.execute(
select(SimCards)
.from_statement(text(paginated_sql_query)), parameters)
.scalars()
I tried to pass an array on the select like that but without result :( :
result_rows = session.execute(
select( [SimCards, func.count().over().label('full_count')] )
.from_statement(text(paginated_sql_query)), parameters )
.scalars()
My need is to have the total count in only one query with my paginated results and to know how to exploit it after.
full_countin the view being selected ?