Results 1 to 14 of 14
  1. #1
    Join Date
    Dec 2011
    Posts
    8

    Unanswered: case in-sensitive sql querry

    Hi,

    In the interview test one of the questions was asked in which I have doubt is below-:

    If a table has a VARCHAR columns, containing values: prod,system,PROD,Test,Prod. Which one of the following queries will find all the records containing 'PROD' irrespective of the case?

    a) SELECT * FROM TABLE WHERE COLUMN=IGNORE_CASE('PROD')
    b) SELECT * FROM TABLE WHERE COLUMN=LOWER_CASE('prod')
    c) SELECT * FROM TABLE WHERE LCASE(COLUMN)='prod'
    d.) None of these
    My answer was a)

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Wrong, try again.

    Andy

  3. #3
    Join Date
    Dec 2011
    Posts
    8
    Quote Originally Posted by ARWinner View Post
    Wrong, try again.

    Andy
    I don't know the answer that is why I posted this question on the forum.
    Any suggestions are wecome

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    The object here is to get you to figure out the correct answer. You can read the manuals to see what information you can use. Or you can just use a little common sense to figure it out.

    Andy

  5. #5
    Join Date
    Dec 2011
    Posts
    8
    Answer is d

  6. #6
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by Ankoo View Post
    Answer is d
    Why do you think that?

    Andy

  7. #7
    Join Date
    Dec 2011
    Posts
    8
    because 'Prod' includes both upper and lower case.

  8. #8
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by Ankoo View Post
    because 'Prod' includes both upper and lower case.
    That is true, but your answer is wrong.

    Andy

  9. #9
    Join Date
    Dec 2011
    Posts
    8
    the answer is c, i understood the question wrong.
    Thanks Andy

  10. #10
    Join Date
    Dec 2011
    Posts
    8
    Hi,

    If we want all Prod,PROD and prod then how would the query look like.
    Any suggestions are welcome.

  11. #11
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You have the answer for this already.

    Andy

  12. #12
    Join Date
    Dec 2011
    Posts
    8
    Hi,

    I found the below statement from the manual.

    The schema is SYSIBM.
    The LCASE function returns a string in which all the characters have been converted to lowercase characters.

    That means Prod and PROD will not be coming in output. So answer is d.

  13. #13
    Join Date
    Sep 2011
    Posts
    16
    Hi,

    The answer is c.

    SELECT * FROM TABLE WHERE LCASE(COLUMN)='prod' will give u the right answer.


    Ashish

  14. #14
    Join Date
    Dec 2011
    Posts
    8
    Hi,

    I think I got it, it will convert all the prod to lower case and select 'prod' then in that case
    SELECT * FROM TABLE WHERE UCASE(COLUMN)='PROD' will also work just fine.

Posting Permissions

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