how can I write HAVING query! can please lem me know thanks.
NOTE : [I][This question was asked by patel] [/I]
Printable View
how can I write HAVING query! can please lem me know thanks.
NOTE : [I][This question was asked by patel] [/I]
Hi Patel,
Go to quick links, click on private messages,click on new messages.Post ur query it will automatically come on forum.
I hope your query solve.Plz revert me with feed back or any further query.
Thanks & Regards
Nikhil Rattan
Hi Patel,
The HAVING clause is used in combination with the GROUP BY clause. It can be used in a SELECT statement to filter the records that a GROUP BY returns.
HAVING clause is used with aggregate_function like SUM, COUNT, MIN, or MAX.
Let me give an HAVING clause example with COUNT function.
SELECT dept_no, COUNT(*)
FROM employees
WHERE salary > 25000
GROUP BY dept_no
HAVING COUNT(*) > 10;
This example will select the No. of employees of all deptartments with salary greater than 25000. Here the HAVING clause filters the records with departments which have more than 10 employees.
Similarly other aggregate functions can be used.
Hope its clear :-)
*** Mangai Varma ***