Hello.
I have a schema/table which contains the following field types:
name : string
has_activated : bool
is_online : bool
How would I return the different permutations of the boolean values with each count and give a name to this pair?
I thought about using group_by
on both columns with count
and I think I could receive the following:
True, True, 10
False, False, 15
True, False, 20
How could I give a name to each pair? For example:
{
online_and_activated: 10,
not_online_not_activated: 15,
not_online_and_activated: 20
}
Would I use something like select: %{}
with |
to change a value? I would need to use each group and make a new name for it with the resulting count.
Additionally, if I did this, would it also be possible return each row for each of those groups? Or should I just return every row with the addition of the summarized data above and do that part in the view/template with Elixir?
Thanks!