Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> SUM and GROUP BY...
This sentence works perfectly:
select field_name, sum(numbers) as numbers
from topten
group by field_name
order by numbers desc
While this sentence:
select field_name, sum(numbers) as numbers
from topten
group by field_name, date_field
having months_between(sysdate,date_field)<1
order by numbers desc;
The first sentence summarises the "numbers" for each field_name and then lists them out like this:
field 1 123 field 3 45 field 2 23
While sentence two which should do the same, just within a certain
daterange like months, weeks, years, lists this double double shit:
field 1 100
field 3 14
field 1 23
field 2 20
field 2 3
How can I go round this?
Ole C. Received on Thu Mar 29 2001 - 06:34:05 CST
![]() |
![]() |