‎2007 May 31 12:23 PM
Hi,
May I know aggregate function sum, count, max, min, average in select statement need to have group by?
I know sum need to have, what about others?
Thanks
‎2007 May 31 12:25 PM
Hi
If you are using aggregate functions, then its necessary for you to use <b>group by</b> clause.
Eg:
SELECT d.depid, d.name, COUNT(*) AS EMPLOYEE_COUNT
FROM department d JOIN employee e
ON
d.DEPID = e.DEPID
GROUP BY d.depid, d.name
Regards
Raj
‎2007 May 31 12:25 PM
Hi
If you are using aggregate functions, then its necessary for you to use <b>group by</b> clause.
Eg:
SELECT d.depid, d.name, COUNT(*) AS EMPLOYEE_COUNT
FROM department d JOIN employee e
ON
d.DEPID = e.DEPID
GROUP BY d.depid, d.name
Regards
Raj
‎2007 May 31 12:26 PM
if you are using aggregate fn and other fields also in select statement then you have to use groupby for other fields.
suppose
select mblnr sum( menge ) into table itab from mseg where bwart = '101' group by mblnr.
since mblnr is not in aggregate fn so you have to use mblnr in group by clause (it may be any no of fields without aggregate fn) if you are using simply aggregate fn then no need of group by
select sum( menge ) into table itab from mseg where bwart = '101' .
regards
shiba dutta
‎2007 May 31 12:31 PM
Hi,
I know if having other fields as well then other field need to have group by/order by for sum.
Can let me know if the rest like count, max, min, average also need to have group by /order by
thanks
points given.
‎2007 May 31 12:27 PM
if u r using more dan one field in da select clause den u hav to specify teh grp by caluse otherwise nt..