Class HavingScope

Object
gudusoft.gsqlparser.resolver2.scope.AbstractScope
gudusoft.gsqlparser.resolver2.scope.HavingScope
All Implemented Interfaces:
IScope

public class HavingScope extends AbstractScope
Scope for HAVING clause.

Visibility rules: - Can access GROUP BY columns - Can access aggregate functions - Can access SELECT list aliases (in some databases) - Cannot access non-aggregated columns not in GROUP BY

Example:

 SELECT department, COUNT(*) as emp_count
 FROM employees
 GROUP BY department
 HAVING COUNT(*) > 10  -- Can use aggregates
    OR emp_count > 10  -- Can use SELECT list alias (database-dependent)
 

The HAVING scope has access to: - GROUP BY scope (for grouped columns) - SELECT scope (for SELECT list aliases, database-dependent)

  • Constructor Details

  • Method Details

    • setGroupByScope

      public void setGroupByScope(IScope groupByScope)
      Set the GROUP BY scope for column resolution. HAVING can reference columns that appear in GROUP BY.
      Parameters:
      groupByScope - the GROUP BY scope
    • setSelectScope

      public void setSelectScope(IScope selectScope)
      Set the SELECT scope for alias resolution. HAVING can reference SELECT list aliases in some databases.
      Parameters:
      selectScope - the SELECT scope
    • getGroupByScope

      Get the GROUP BY scope.
      Returns:
      the GROUP BY scope, or null if not set
    • getSelectScope

      Get the SELECT scope.
      Returns:
      the SELECT scope, or null if not set
    • getHavingCondition

    • toString

      public String toString()
      Overrides:
      toString in class AbstractScope