0
votes

Currently I have a PostgreSQL query which calculates expression: SELECT sum(timestamp2 - timestamp1 [some other math]) from <...> WHERE <...>.

Is there a way to do it with Slick? I tried to fetch raw data (login and logout) from database and process it, but this method is too expensive, so I need to process data on the database side.

1
Go ahead and say that question title five times fast.Silvio Mayolo

1 Answers

0
votes

This is how you do calculated columns

https://github.com/slick/slick/issues/1314

So in your case it will be

def ts(row: YourTableClass[_]) = row.timestamp2 -- row.timestamp1

Next you can do aggregation like shown in nmat's link