please help me to develop this query

  • Hi,

    I need your help to develop a query with the date between current month and current month + 11 months.

    my table contains below data

    tbl1

    -------

    name dt

    xxx 01-Apr-2010

    xyz 02-May-2010

    abc 01-Mar-2010

    I need all 12 months in the same dt column. As of now dt column contains values for mar,apr,may but i need all other months in the same column.

    Please help me it is very urgent.

    Thanks in advance.

    Madhuri

  • Not exactly sure what you are asking, so to help us help you, please read and follow the instructions in the first article i reference below in my signature block. In addition, please provide the expected results based on the sample data.

    Doing this will make it easier for us to help you, please the added benefit is that you will get tested code in return.

  • Not sure of what is the requirement. Can u please elborate more with an example?

  • Why do you have MAY 2nd in your list instead of May 1st?

    What data format is your dt column?

    Please help us help you.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Hi,

    Thanks for your suggestions. I am posting the output of the results which needs to come.

    my table contains below data

    tbl1

    -------

    name dt

    xxx 01-Apr-2010

    xyz 02-May-2010

    abc 01-Mar-2010

    results should come like below

    name dt

    xxx 01-Apr-2010

    xyz 02-May-2010

    abc 01-Mar-2010

    xxx 01-Jun-2010

    xxx 01-Jul-2010

    xxx 01-Aug-2010

    xxx 01-Sep-2010

    xxx 01-oct-2010

    xxx 01-Nov-2010

    xxx 01-Dec-2010

    xxx 01-Jan-2011

    xxx 01-Feb-2011

    Thanks in advance.

    Madhuri

  • madhuri-425013 (3/15/2010)


    Hi,

    Thanks for your suggestions. I am posting the output of the results which needs to come.

    my table contains below data

    tbl1

    -------

    name dt

    xxx 01-Apr-2010

    xyz 02-May-2010

    abc 01-Mar-2010

    results should come like below

    name dt

    xxx 01-Apr-2010

    xyz 02-May-2010

    abc 01-Mar-2010

    xxx 01-Jun-2010

    xxx 01-Jul-2010

    xxx 01-Aug-2010

    xxx 01-Sep-2010

    xxx 01-oct-2010

    xxx 01-Nov-2010

    xxx 01-Dec-2010

    xxx 01-Jan-2011

    xxx 01-Feb-2011

    Thanks in advance.

    Madhuri

    I'll second what Lutz asked...

    Why do you have MAY 2nd in your list instead of May 1st?

    What data format is your dt column?

    Please help us help you.

    Otherwise, I am posting the article that will teach you how to make "the output of the results which needs to come". 😉

    http://qa.sqlservercentral.com/articles/T-SQL/62867/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Hi,

    Thanks for your valuable suggestion.

    Thanks,

    Madhuri

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply