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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old April 1st, 2004, 11:37 AM
rmarsha rmarsha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 14 rmarsha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Another to_date() question

Hello,
I've got a SQL statement that pulls data based on to_date('January 2000', 'Month yyyy') that returns results, but it is not calendar aware. The order by won't let me sort by 'calendar position', instead it just sorts alphabetically by the month. Here is my statement:

SELECT to_char(a.row_add_tms, 'Month yyyy') as row_add_date, b.DCMNT_CLASS_TYPE_DESC,a.dcmnt_class_seq_nbr, sum(a.img_qty) img_qty
FROM dcmnt_cmit_cnt a, dcmnt_class_type b, rpt_grp_type c
WHERE a.DCMNT_CLASS_SEQ_NBR = b.DCMNT_CLASS_SEQ_NBR
AND c.rpt_grp_typ_cd = '3' AND c.rpt_grp_typ_cd = b.rpt_grp_typ_cd
AND a.row_add_tms >= to_date('January 2000', 'Month yyyy')
AND a.row_add_tms <= to_date('December 2004', 'Month yyyy')
GROUP BY a.DCMNT_CLASS_SEQ_NBR, to_char(a.row_add_tms, 'Month yyyy'), b.DCMNT_CLASS_TYPE_DESC
ORDER BY to_char(row_add_tms, 'Month yyyy'), b.dcmnt_class_type_desc;

Any suggestions?
Thanks, -Rick

Reply With Quote
  #2  
Old April 2nd, 2004, 02:28 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,711 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 6 Days 5 h 22 m 58 sec
Reputation Power: 259
Your problem lies in
Quote:
ORDER BY to_char(row_add_tms, 'Month yyyy'),

you are not ordering by a date, but by a char, so it
Quote:
sorts alphabetically by the month

Use the original field.

Reply With Quote
  #3  
Old April 2nd, 2004, 08:38 AM
rmarsha rmarsha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 14 rmarsha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That had occured to me yesterday after I posted. Thanks-

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Another to_date() question


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 5 hosted by Hostway