Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Sum if query #5

bigbentobox opened this Issue · 1 comment

2 participants


Is it posisble to a make a query that do a sum with if inside?

For example :

SUM(if( users.origin IS NULL, 1,0))

Checked the documentation but don't find the if statement, there is a workaround?



Could you show me the full query you want to perform, including the model you are querying against?

You could use a virtual column:

So you would do:

render :rgviz => User, :virtual_columns => {
    'user_origin_is_null' => {
        :sql => "case when users.origin is null then 1 else 0 end",
        :type => :string

I'm not sure you can do "if" in SQL (in GQL I know you can't)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.