private void addGroupBySelectedFields()
   {
      DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode) ((BrowserItems.DefaultTreeItem) 
            node.getParent()).getFirstChild();
      
      for (int i = 0; i < selectNode.getChildCount() ; i++)
      {
         BrowserItems.DefaultTreeItem item = (BrowserItems.DefaultTreeItem)selectNode.getChildAt(i);
         
         if (item.getUserObject() instanceof QueryTokens._Expression)
         {
            final QueryTokens._Expression itemToken = (QueryTokens._Expression)item.getUserObject();
            
            // should take all columns and functions/ operations that are not aggregate functions
            // ( count, sum, avg, min, max ) example: select 1, f(a), 'gg', count(*) from group by 1,
            // f(a), 'gg' 
            
            boolean addToGroupby = false;
            
            if (itemToken instanceof  QueryTokens.Column)
            {
               addToGroupby = true;
            }
            else if (itemToken instanceof  QueryTokens.DefaultExpression)
            {
               final String val = ((QueryTokens.DefaultExpression)itemToken).getValue();
               
               if (val!=null)
               {
                  addToGroupby = true;
                  
                  final String valLower = val.toLowerCase();
                  
                  for (final String aggregate : QueryBuilderPane.AGGREGATE_FUNCTIONS)
                  {
                     if (valLower.startsWith(aggregate.toLowerCase()))
                     {
                        addToGroupby = false;
                        break;
                     }
                  }
               }
            }
            if (addToGroupby)
            {
               queryBuilderPane.sqlBrowserViewPanel.addGroupByClause(new QueryTokens.Group(itemToken));
            }
         }
      }
   }