SelectWithUnionQuery (children 1)
 ExpressionList (children 1)
  SelectQuery (children 4)
   ExpressionList (children 3)
    Identifier loyalty
    Function count (alias c) (children 1)
     ExpressionList
    Function bar (children 1)
     ExpressionList (children 4)
      Function multiply (children 1)
       ExpressionList (children 2)
        Function log (children 1)
         ExpressionList (children 1)
          Function plus (children 1)
           ExpressionList (children 2)
            Identifier c
            Literal UInt64_1
        Literal UInt64_1000
      Literal UInt64_0
      Function multiply (children 1)
       ExpressionList (children 2)
        Function log (children 1)
         ExpressionList (children 1)
          Literal UInt64_3000000
        Literal UInt64_1000
      Literal UInt64_80
   TablesInSelectQuery (children 2)
    TablesInSelectQueryElement (children 1)
     TableExpression (children 1)
      TableIdentifier test.hits
    TablesInSelectQueryElement (children 2)
     TableExpression (children 1)
      Subquery (children 1)
       SelectWithUnionQuery (children 1)
        ExpressionList (children 1)
         SelectQuery (children 2)
          ExpressionList (children 2)
           Identifier UserID
           Function toInt8 (alias loyalty) (children 1)
            ExpressionList (children 1)
             Function multiply (children 1)
              ExpressionList (children 2)
               Function if (children 1)
                ExpressionList (children 3)
                 Function greater (children 1)
                  ExpressionList (children 2)
                   Identifier yandex
                   Identifier google
                 Function divide (children 1)
                  ExpressionList (children 2)
                   Identifier yandex
                   Function plus (children 1)
                    ExpressionList (children 2)
                     Identifier yandex
                     Identifier google
                 Function divide (children 1)
                  ExpressionList (children 2)
                   Function negate (children 1)
                    ExpressionList (children 1)
                     Identifier google
                   Function plus (children 1)
                    ExpressionList (children 2)
                     Identifier yandex
                     Identifier google
               Literal UInt64_10
          TablesInSelectQuery (children 1)
           TablesInSelectQueryElement (children 1)
            TableExpression (children 1)
             Subquery (children 1)
              SelectWithUnionQuery (children 1)
               ExpressionList (children 1)
                SelectQuery (children 5)
                 ExpressionList (children 3)
                  Identifier UserID
                  Function sum (alias yandex) (children 1)
                   ExpressionList (children 1)
                    Function equals (children 1)
                     ExpressionList (children 2)
                      Identifier SearchEngineID
                      Literal UInt64_2
                  Function sum (alias google) (children 1)
                   ExpressionList (children 1)
                    Function equals (children 1)
                     ExpressionList (children 2)
                      Identifier SearchEngineID
                      Literal UInt64_3
                 TablesInSelectQuery (children 1)
                  TablesInSelectQueryElement (children 1)
                   TableExpression (children 1)
                    TableIdentifier test.hits
                 Function or (children 1)
                  ExpressionList (children 2)
                   Function equals (children 1)
                    ExpressionList (children 2)
                     Identifier SearchEngineID
                     Literal UInt64_2
                   Function equals (children 1)
                    ExpressionList (children 2)
                     Identifier SearchEngineID
                     Literal UInt64_3
                 ExpressionList (children 1)
                  Identifier UserID
                 Function greater (children 1)
                  ExpressionList (children 2)
                   Function plus (children 1)
                    ExpressionList (children 2)
                     Identifier yandex
                     Identifier google
                   Literal UInt64_10
     TableJoin (children 1)
      ExpressionList (children 1)
       Identifier UserID
   ExpressionList (children 1)
    Identifier loyalty
   ExpressionList (children 1)
    OrderByElement (children 1)
     Identifier loyalty
