Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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!


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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.