Software Testing

k2G9Eo9
RdZQRt6

Popular Posts

Having


The HAVING Clause is used to filter data based on the GROUP function. This is similar to WHERE condition but it is used with GROUP BY function. Group By Function cannot be used in WHERE clause but can be used in HAVING clause.
The basic syntax is as follows:
SELECT column1, column2, ... column_n Aggregate_Function(Column) 
FROM tables WHERE conditions 
GROUP BY column1, column2, ... column_n HAVING condition;
Employee
Emp_idNameSurnameSalaryDept_id
1RajeshKhanna450002
2SnehaGupta550004
3SandeepNehte950001
4KirtiPatil250003
5NileshJadhav450003
6DipeshDas350005
7KailashRane620001
8KavitaDeshpande480003
9SanjayDatt500003
10ShrutiHasan780001

Parameters or Arguments
  • aggregate_function
    • A function such as SUM, COUNTMINMAX, or AVG functions.
  • column1, column2, ... column_n
    • The columns that are not encapsulated within an aggregate function and must be included in the GROUP BY clause.
  • condition
    • The condition that is used to restrict the groups of returned rows. Only those groups whose condition evaluates to TRUE will be included in the result set.
    Syntax For SQL:
    SELECT Emp_id, Name, SUM(salary) 
    FROM employee WHERE salary>45000 
    GROUP BY Name HAVING Sum(salary)>45000
    After Execute: 
    Emp_idNameSalaryDept_id
    3Sandeep950001
    10Shruti780001
    7Kailash620001
    2Sneha550004
    9Sanjay500003
    8Kavita480003
    1Rajesh450002
    5Nilesh450003

    No comments:

    Post a Comment

    BESbswy