Is it possible to use Aggregate function in a Select statment without using Group By clause?

Viewed 70340

So far I have written Aggregate function followed by Group By clause to find the values based on SUM, AVG and other Aggregate functions. I have a bit confusion in the Group By clause. When we use Aggregate functions what are the columns I need to specify in the Group By clause. Otherwise Is there any way to use Aggregate functions without using Group By clause.

7 Answers

Yes, without aggregate functions we can use group by column but it will be a distinct function.

select <column name> from <table name> group by <column name> 

Given the table EMP:

select * from EMP

That outputs:

7369    SMITH   CLERK       7902
7499    ALLEN   SALESMAN    7698
7521    WARD    SALESMAN    7698
7566    JONES   MANAGER     7839

Adding a group by

select job from EMP group by job

Outputs:

CLERK
SALESMAN
MANAGER
Related