How to convert this PostgreSQL
query to an Ecto
piped select expression:
select CEIL ( CAST ( records."duration" AS DECIMAL ) / 60 ) from records
where "duration" is not null
Thank you.
How to convert this PostgreSQL
query to an Ecto
piped select expression:
select CEIL ( CAST ( records."duration" AS DECIMAL ) / 60 ) from records
where "duration" is not null
Thank you.
Solved, the way to do it is using fragment
.
and no code snippet??
Like this:
Record
|> select([record], %{
total: fragment("sum(CEIL ( CAST (? AS DECIMAL ) /60 )) / 2", record.duration)
})
|> Repo.one