Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Is there fast way to group by MMYY ( date type)
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C050D0.090954C0
Content-Type: text/plain;
charset=iso-8859-1
Content-Transfer-Encoding: 7bit
I'm having a hard time to group by month.
subs table has id, and sub_date (date type) and it's huge table.
When I group by month as follow, it's really slow. and I cannot order by
month correctly.
select to_char(sub_date, 'MM/YY') as date_ent, to_char(sub_date,'YYMM') as
revdate, count(id) as count
from subs
group by to_char(sub_date,'YYMM'), to_char sub_date,'MM/YY')
order by to_char(sub_date,'YYMM') desc
Is there any fast way to do this without usnding to_char?
Thank you.
------_=_NextPart_001_01C050D0.090954C0
Content-Type: text/html;
charset=iso-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=870244219-17112000>I'm having a hard
time to group by month. </SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=870244219-17112000>subs table has id,
and sub_date (date type) and it's huge table</SPAN></FONT><FONT face=Arial
size=2><SPAN class=870244219-17112000>.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=870244219-17112000>When I group by
month as follow, it's really slow. and I cannot order by month
correctly.</SPAN></FONT></DIV>
<DIV><SPAN class=870244219-17112000>
<P><FONT face=Arial size=2>select to_char(sub_date, 'MM/YY') as date_ent,
to_char(sub_date,'YYMM') as revdate, count(<SPAN
class=870244219-17112000>id</SPAN>) as count<BR>from subs<BR>group by
to_char(sub_date,'YYMM'), to_char sub_date,'MM/YY')<BR>order by
to_char(sub_date,'YYMM') desc<BR></FONT></P>
<P><FONT face=Arial size=2><SPAN class=870244219-17112000>Is there any fast way
to do this without usnding to_char?</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN class=870244219-17112000>Thank
you.</SPAN></FONT></P></SPAN></DIV></BODY></HTML>
Received on Fri Nov 17 2000 - 13:53:20 CST
![]() |
![]() |