Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 19th, 2010, 03:47 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ordering the retrieved dates from Database

I am retrieving the data from Oracle using JDBC API. I want to get the last 24 months starting from current month and the respective count of records.
I wrote the query as shown below:
(TIMESTAMP is of Data type DATE)

SELECT MONTH_YEAR,SUM(MONTH_COUNT) FROM
(SELECT
REPLACE(TO_CHAR(TIMESTAMP,'MON-YYYY'),'-','_') AS MONTH_YEAR, 1 AS MONTH_COUNT
FROM
MASTER
WHERE
TIMESTAMP >= TRUNC((ADD_MONTHS(SYSDATE, -24)),'MM'))
GROUP BY MONTH_YEAR

However, i cannot order by MONTH_YEAR as that will be ordered by alphabets(A,B,C..) as MONTH_YEAR is a string.
What i would appreciate is if anyone could point me how to order the result by date either on the DB query or on the Java end.

Thanks in advance!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I compare dates in a sqlserver database to ysfkay ASP.NET 3.5 Basics 3 December 4th, 2009 11:00 AM
how can I compare dates in a sqlserver database to ysfkay ASP.NET 3.5 Professionals 3 December 1st, 2009 11:13 AM
Populate textbox with data retrieved from database hoailing22 ASP.NET 1.0 and 1.1 Basics 5 November 30th, 2006 12:13 AM
highlight results retrieved from database dhaywirex Classic ASP Basics 0 February 24th, 2004 04:06 AM
Getting info from database -between dates doranaz Classic ASP Databases 2 December 23rd, 2003 01:02 AM



All times are GMT -4. The time now is 07:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.