I'd like to execute a query like this using ENT:
select
some_column,
count(*)
from some_table
group by some_column
order by count desc
limit 10
I.e. to get the top N of some records using an aggregate. I couldn't figure out how to do the order, it seems ENT to only allows to sort by column names in the table. I rather not query all data and sort in memory, because there might be many records.
This is what i have:
entClient.
SomeTable.
Query().
Order(ent.Desc("count")).
GroupBy(sometable.FieldSomeColumn).
Aggregate(ent.Count()).
Scan(ctx, &v)
I thought i can "hack" it by using the string "count"
but it returns ent: unknown column "count" for table "some_table"
.
Is it possible to do this or do i need to use raw sql queries?