Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL problem using count and group by with date datatype
You only have to change your "order by" to a "group by".
smceneaney_at_my-deja.com a écrit dans le message <7r3am9$kuk$1_at_nnrp1.deja.com>...
>I want to count records in a table using group by on a date datatype.
>The problem is that I want to use ONLY the dd-mon-yy part of the date in
>the count function and group by function. I want to group by the day
>part of the date field and not day and time. The SQL query below fails
>
>select count(register_date), to_char(register_date, 'dd-mon-yy')
>from user_table
>where (register_date - to_date('01-Aug-99', 'dd-mon-yy') > 0)
>order by to_char(register_date, 'dd-mon-yy')
>
>with the following error
>
>ERROR at line 1:
>ORA-00937: not a single-group group function
>
>The result I want to get is something like this
>
>5 1-AUG-99
>7 2-AUG-99
>99 4-AUG-99
>100 9-AUG-99
>150 12-AUG-99
>8 13-AUG-99
>89 21-AUG-99
>
>
>Can anybody tell me what I'm doing wrong??
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Tue Sep 07 1999 - 11:18:04 CDT
![]() |
![]() |