trouble with 'group by' [message #4467] |
Thu, 12 December 2002 04:02 |
philarmo
Messages: 15 Registered: February 2002
|
Junior Member |
|
|
hi,
i tried to make a group by with a column date but not works. here is my request :
select TO_CHAR (datequestion, 'YEAR'), count(*) "total"
from interventions_in_progress
group by datequestion
the answer shows that :
TO_CHAR(DATEQUESTION,'YEAR') total
TWO THOUSAND ONE 1
TWO THOUSAND ONE 1
TWO THOUSAND ONE 1
TWO THOUSAND ONE 1
TWO THOUSAND TWO 1
TWO THOUSAND TWO 1
So why the date are not grouping ?
|
|
|
Re: trouble with 'group by' [message #4472 is a reply to message #4467] |
Thu, 12 December 2002 10:53 |
Arathi
Messages: 9 Registered: November 2002
|
Junior Member |
|
|
You want to group and count the rows with the same year?? Then you missed the year part in the group by clause
select TO_CHAR (datequestion, 'YEAR'), count(*) "total"
from interventions_in_progress
group by TO_CHAR (datequestion, 'YEAR');
You previously grouped it with the full date field and bcos the dates may have different month and date, the output gave different rows.
HTH,
Arathi
|
|
|
|