Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to retrieve data between months

923578Apr 10 2012 — edited Apr 10 2012
By simply said that....I have a sql to show this table:
ID YEARS MONTHS SM
-- ----- ------ --
 1  2009 Jan    54662 
 1  2009 Feb    23467 
 1  2009 Mar    25246 
 1  2009 Apr    35556 
 1  2009 May    35856 
 1  2009 Jun    46200 
 1  2009 Jul    69411 
 1  2009 Aug    26030 
 1  2009 Sep    26276 
 1  2009 Oct    21192 
 1  2009 Nov    68508 
 1  2009 Dec    43701 
 1  2010 Jan    35448 
 1  2010 Feb    26564 
 1  2010 Mar    60720 
 1  2010 Apr    59606 
 1  2010 May    53005 
 1  2010 Jun    37847 
 1  2010 Jul    35977 
 1  2010 Aug    70383 
 1  2010 Sep    35701 
 1  2010 Oct    43946 
 1  2010 Nov    35739 
 1  2010 Dec    72686 

 24 rows selected 
SQL that I am using:
select id,years,months,sm from test_v2
where years in (2009,2010) 
I have tried this statement but it shows very strange for only taking Jan,Jun and Jul but not months between Jan-Jun...
select id,years,months,sm from test_v2
where years in (2009,2010) 
and
(months between 'Jan' and 'Jun')
Please help for retrieving the value between Jan and Jun.....
Thanks everyone helps :)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2012
Added on Apr 10 2012
11 comments
250 views