Results 1 to 4 of 4

Thread: need help in writing T-Sql Querey

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    need help in writing T-Sql Querey

    hi There,

    I have a Database table which has about 90 columns in it.
    But for writing this particular querey It needs only few of them.

    I'll list them here!

    Acc BegDt EnDt J F M A MY Jn Jy Au S O N D
    10 1/2008 12/2008 1 1 1 1 1 1 0 0 0 0 0 0


    First Querey:

    "Based On The BegDt, Count the no of months that has a value>0 for acc10, and continues until it reaches a 0 value."

    Note: BegDt n EnDt are in Char DataType:

    Second Querey:

    "Find The Value of The 'number' . where number is the value for acc 10 based on the startdate."


    Can Any one please Help me soon. Its really very Urgne..!!

    ThAnKs..

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Sounds homework, ask your classmate for help.

  3. #3
    Join Date
    Nov 2008
    Posts
    2
    Come on Bro..
    Its not a Homework..! This is an assigned task to me..I need to do it...Can Any one please Help me out

  4. #4
    Join Date
    Apr 2009
    Posts
    20

    Suggestion.

    1. USe the CHARindex function first for finding the start month from begdt column by searching with '/'
    for the above example, seems 1.

    2. read all the columns start from J to D in a single column using concatenation by matching with ACC column. here dont need to check the start date.

    3. store the value in one variable for the expression as arrived in step 2.

    4. in the CHARINDEX function itself option of searching from which character is avaiable. the start character must be the start month. Find for Zero.

    5. Whaterver the value is arrived in step 4 that would be the solution.

Posting Permissions

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