Yoavya
08/04/2020, 7:31 AMcolumnX.count()
in the slice part of the query.
I want to do something like this
count(*) filter ( where columnX in ('a', 'b') ) as custom_count
is there an easy way to achieve this?
Thanks 🙂Joel
08/04/2020, 11:34 AMYoavya
08/04/2020, 12:36 PMSELECT COUNT(*) as count, count(*) filter ( where answer.answer in ('yes', 'no') ) as count_having
FROM answer;
this is in PostgresJoel
08/04/2020, 1:28 PMYoavya
08/04/2020, 1:29 PMJoel
08/04/2020, 1:29 PMwrapAsExpression
tapac
08/04/2020, 10:01 PMfun CountWithFilter(condition: SqlExpressionBuilder.() -> Op<Boolean>) =
CustomLongFunction("count(*) filter", SqlExpressionBuilder.condition())
fun main() {
val countFilter = CountWithFilter { AnswerTable.answer inList listOf("yes", "no") }
AnserTable.slice(countFilter).selectAll()
}
Yoavya
08/05/2020, 5:27 AMJoel
08/07/2020, 9:05 PM