Results 1 to 4 of 4

Thread: Query

  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Unanswered: Query

    Hi,

    I have columns like Jan_Prev, Jan_Curr,Feb_Prev,Feb_Curr,.....Dec_Prev,Dec_Curr in one of my table.

    I need a query which should return dynamically by accepting the given parameter.

    For e.g. If my input is May2009, it should return those columns which are less than the given month (May), like May_Curr,Apr_Curr,Mar_Curr,Feb_Curr,Jan_Curr,Dec_P rev,Nov_Prev,Oct_Prev,Sep_Prev,Aug_Prev,July_Prev, June_Prev,May_Prev

    Can any one sort out this?

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool PL/SQL Array

    You could code dynamic SQL, but maybe using PL/SQL Arrays would work best. Load the data into a pl/sql table and then you can use the month number to navigate the array backwards.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    The main problem you have is that your table design is very bad. Simply store the data with a date column then you can find any particular month anytime you want with a simple query.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Thumbs down Sloppy

    Quote Originally Posted by beilstwh
    The main problem you have is that your table design is very bad. Simply store the data with a date column then you can find any particular month anytime you want with a simple query.
    Yes, this is a definite case of sloppy design.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •