Home » SQL & PL/SQL » SQL & PL/SQL » trouble with 'group by'
trouble with 'group by' [message #4467] Thu, 12 December 2002 04:02 Go to next message
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 Go to previous messageGo to next message
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
Re: trouble with 'group by' [message #4477 is a reply to message #4472] Fri, 13 December 2002 02:10 Go to previous message
philarmo
Messages: 15
Registered: February 2002
Junior Member
yes it works now, it was very simple in fact !
thank you
Previous Topic: Table Size
Next Topic: pl/sql var is not getting captured urgent
Goto Forum:
  


Current Time: Thu May 16 11:46:01 CDT 2024