Tutorials Hut

  • SQL Testing




  • SQL Having Statement with Example

    SQL ‘ Having ’ is used with aggregate functions.

      • HAVING clause is used with the GROUP BY clause .
      • It is used filter groups based on a specified list of conditions.
    SELECT
     select_list
    FROM
     table_name
    GROUP BY
     group_list
    HAVING
     conditions;

    Example:

    Consider Employee table having below records.

    SQL Having Select 1.1

    List all DepartmentIDs which have employees Count is greater than 1

    SELECT DepartmentID,COUNT(EmployeeID)
    FROM Employee GROUP BY
    DepartmentID HAVING COUNT(EmployeeID) > 1;
    SQL Having 1.2



  • SQL Testing


















  • Leave a Reply

    Your email address will not be published. Required fields are marked *