Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old June 13th, 2004, 06:14 PM
Plow Plow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 Plow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Group By and time/date stamps

I want to do a Group By "date". However, the time on the end of the stamp does not allow me to group days, as each time of the same day is unique. For example, I want to group everything on 06/02/2004 and ignore the time stamp appended at the end.
Man, I hope that makes sense.
Anyway, thanks in advance for any help you can provide.

Reply With Quote
  #2  
Old June 13th, 2004, 11:45 PM
galith_haham galith_haham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 64 galith_haham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 25 m 17 sec
Reputation Power: 5
Hi,

what you need to do is omit the extention use trunc function (you can trunc to the day, month or year):

select ...
from ...
group by trunc(dt,'mm');

Galit.

Reply With Quote
  #3  
Old June 14th, 2004, 07:03 AM
Plow Plow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 Plow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, I did not know of that function, but I can tell if it works or not because I am now getting the "Not a group by expression".
Any Ideas?

SELECT "branch" as "Service", "FOLLOWUP_DTTM"
FROM "THIS_TABLE"
WHERE ( "FOLLOWUP_DTTM" BETWEEN '05/28/2004' AND '06/11/2004')
GROUP BY TRUNC( "FOLLOWUP_DTTM", 'mm')

Thanks again for any help!

Reply With Quote
  #4  
Old June 14th, 2004, 08:18 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
You suppoese to use the same expression in the SELECT clause that you are using in the GROUP BY clause, furthurmore you cannot use table alias name in GROUP BY clause and you also need a group function expression in your SELECT clause in case if you are using more than one column.
I also think that you should use TO_CHAR function to fetch only days or month or year, Let's see the example:

SELECT TO_CHAR(hiredate,'Mon'), sum(sal)
FROM emp
GROUP BY TO_CHAR(hiredate,'Mon')
/

Reply With Quote
  #5  
Old June 16th, 2004, 07:14 AM
hudo hudo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 97 hudo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 19 sec
Reputation Power: 5
Maybe you search something like:

SELECT TO_CHAR(FOLLOW_DTTM,'mm/dd/yyyy') NO_TIME_STAMP,
sum(branch) Service,
COUNT(*)
FROM YOUR_TABLE
WHERE FOLLOW_DTTM BETWEEN
TO_DATE('05/28/2004/','mm/dd/yyyy')
AND TO_DATE('06/11/2004','mm/dd/yyyy')
GROUP BY TO_CHAR(FOLLOW_DTTM,'mm/dd/yyyy')
ORDER BY NO_TIME_STAMP

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Group By and time/date stamps


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway