Operations on aggregations

28 views
Skip to first unread message

Antonio A. Carrillo

unread,
Sep 15, 2015, 4:37:48 PM9/15/15
to Korma
Hello.

I can't find how to translate the following SQL into Korma:

SELECT SUM(quantity*direction) FROM movements;

I don't know how to represent an operation into aggregation columns using Korma.

Thanks.

Immo Heikkinen

unread,
Sep 23, 2015, 2:11:17 PM9/23/15
to Korma
Unfortunately there's no built-in support for operations. You can use `raw` to represent an operation:

(sql-only (select :movements (fields (sqlfn sum (raw "\"quantity\"*\"direction\"")))))
=> "SELECT SUM(\"quantity\"*\"direction\") FROM \"movements\""

or use `exec-raw` to execute any SQL.

--
You received this message because you are subscribed to the Google Groups "Korma" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlkorma+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages