Home » SQL & PL/SQL » SQL & PL/SQL » Date query
icon5.gif  Date query [message #212917] Mon, 08 January 2007 16:46 Go to next message
swamy99
Messages: 30
Registered: June 2006
Member
This was posted in newbies but did not get any good response. Posting in SQL Experts for any expert advise.


I have a table with a date_field that has dates from 01-Jan-2000 through 31-Dec-2006. Using this date_field, I would like to get a start_date and End_date based on six months difference.

Table_data
-----------

date_field
-----------
01-Jan-2000
02-Jan-2000
03-Jan-2000
.....
.....
28-Dec-2006
29-Dec-2006
30-Dec-2006
31-Dec-2006


Now I want to have two columns aliases as Start_Date and End_Date from the above table. All the dates starting from 01-Jan-2000 through 30-Jun-2000 should come under distinct Start_date as 01-Jan-2000 and End_date as 30-Jun-2000. The next row start_date will be from 01-Jul-2000 and end_date will be 31-DEC-2000 and so on until 31-Dec-2006.


The results should look like this.

start_Date End_Date
----------- -----------
01-Jan-2001 30-Jun-2001
01-Jul-2001 31-Dec-2001
01-Jan-2002 30-Jun-2002
01-Jul-2002 31-Dec-2002
01-Jan-2003 30-Jun-2003
01-Jul-2003 31-Dec-2003
.....
.....
01-Jan-2006 30-Jun-2006
01-Jul-2006 31-Dec-2006


How do we get this using a sql statement. Thanks.
Re: Date query [message #212921 is a reply to message #212917] Mon, 08 January 2007 17:41 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
Stop cross/multiple posting!
This the 3rd thread you've started.
Re: Date query [message #212922 is a reply to message #212921] Mon, 08 January 2007 18:06 Go to previous messageGo to next message
swamy99
Messages: 30
Registered: June 2006
Member
Since I did not get a desired answer, I have posted in this SQL Experts section requesting experts advise. Sorry if you think it is a cross post, but I am trying to find a solution here and not to hurt anyone.
Re: Date query [message #212923 is a reply to message #212917] Mon, 08 January 2007 18:15 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
What business problem are you trying to solve?
Re: Date query [message #212924 is a reply to message #212923] Mon, 08 January 2007 18:40 Go to previous messageGo to next message
swamy99
Messages: 30
Registered: June 2006
Member
If you are unable to help resolve the problem, then leave it alone. I have seen several of your posts with not much help to the actual posts or with just one line replies/minimal help with lots of research answers. If you know how to help and resolve the problem quickly, then help or else please do not waste your time in replying vaguely. Thanks
Re: Date query [message #212938 is a reply to message #212917] Mon, 08 January 2007 21:08 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
You have yet to clearly state what business issue you are trying to resolve.

I gave 2 code examples in the Newbies forum neither of which you have recognized.


WHAT are you trying to do ???

Re: Date query [message #212943 is a reply to message #212917] Mon, 08 January 2007 21:25 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
MarcL
>WHAT are you trying to do ???
I suspect the OP is attempting to solve a homework problem for a beginning SQL class.
HAND!
Re: Date query [message #212976 is a reply to message #212943] Tue, 09 January 2007 00:05 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
@OP
If you think you did not get 'any good response' in the newbie forum, say so in a reply to your original thread. Do not start another thread in another forum about the same issue.
Most people that read this Expert forum read the Newbie forum as well.
I will lock this one. Continue in the original thread.
Previous Topic: New to Oracle (merged)
Next Topic: prime no through pl/sql
Goto Forum:
  


Current Time: Sat Dec 03 22:10:52 CST 2016

Total time taken to generate the page: 0.08062 seconds