ABout SELECT Query
I have a custom table where user maintains the data in the following format.
project month year amt1 amt2 amt3
proj1 april 2009 100.00 25.50 356.00
proj1 may 2009 100.00 25.50 356.00
proj1 june 2009 100.00 25.50 356.00
Now i would like to query this table based on Project, Month and Year.
select * from TABLE
into table itab
where pspid = v1
and month between v_month1 and v_month2
and year = v_year.
Here v_month1 = april and v_month2 = june.
Hence i would like to get the data from month april to june (april, may and june rows).
How to write code for this selection...???
The easy answer is to use the month number in the table rather than the name, but I guess you are where you are.
What you'll need to do is convert the from and to month to numbers (e.g. april = 04, june = 06).
Then turn this range into a list (e.g. 04, 05, 06).
Then turn the list of numbers into a list of months (e.g. april, may, june)
In your select statement you should then check that month is in this list.
But I'd just redesign the table.