It works as WHERE clause for aggregate functions.
Example - You need to know city wise max salaries of employees where the max salary is more than 2150.
select max(e.empsal) max_sal, d.depcity
from emp e, deptt d
where e.depid = d.depid
group by d.depcity
having max(e.empsal) > 2150 -- to show max sal > 2150
order by d.depcity
;
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Please login to comment
2 Comments
when to use alias clause ? could we have another way of writing above staement instead of (e.empsal) and d.depcity...
Upvote ShareYes, you can write table name directly too such as emp.empsal and deptt.depcity. Alias is used to make things more handy. Currently you may not require it much, but when writing big queries, you will need it. There are table names that are too big and you don't want to write it again and again. You can use alias in such case. You will also learn about subqueries in later chapters. There you will need alias much.
Upvote Share