SQL Query Help

  • create table T

    (COL1 VARCHAR (50),

    Note VARCHAR (50)

    )

    Insert into T(col1)

    values ('abc')

    Insert into T(col1)

    values ('123-abc')

    Insert into T(col1)

    values ('Hello! This is a Test')

    Insert into T(col1)

    values ('Test successful!')

    When "col1" has more than 10 chars then "Note" should be populated with the same value as in "col1"

    expected result:

    Col1 Notes

    abc Null

    23-abc Null

    Hello! This is a Test Hello! This is a Test

    Test successful! Test successful!

  • If you have a question, please ask it. Don't present information and expect us to understand.

    Second, you need to make an attempt. We are not here to do homework/exams/interview questions. We are happy to help, but if you have not made any effort, then we are not doing the work for you.

  • select Col1,

    case when len(Col1)>10 then Col1 end as Note

    from T

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Hi Steve,

    I was in such a hurry that i clicked post instead of preview. I realized later. I am sorry for that.

  • Mark,

    Thank you. This worked. Thanks for the link. I will surely read it.

Viewing 5 posts - 1 through 4 (of 4 total)

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