Question

How does grouping work with some of the built-in SQL functions

How does grouping work with some of the built-in SQL functions

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SQL has numerous built-in aggregate functions such as COUNT, MAX, MIN, AVG etc. The GROUP BY clause specifies how to group rows from a data table when aggregating information.

For example following SQL statement would give count of all students:

SELECT COUNT(*)

FROM STUDENTS;

But by using GROUP BY, counts acording to degree can be found:

SELECT DEGREE, COUNT(*)

FROM STUDENTS

GROUP BY DEGREE;

The attribute which forms basis of grouping should be included in GROUP BY clause. Then SQL groups record on basis of the attributes mentioned in group by clause and performs required functions.

Another example is to get total salaries paid in each department.

SELECT DEPARTMENT, SUM(SALARY)

FROM EMPLOYEES

GROUP BY DEPARTENT;

Add a comment
Know the answer?
Add Answer to:
How does grouping work with some of the built-in SQL functions
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT