what is mean by '' ? + in where clause

  • Garadin,

    i have tested your code...

    original output:

    aaazzzz

    bbb

    zzz

    ccc

    b

    a

    bb

    i got the below result set...

    bbb

    zzz

    ccc

    bb

    it didn't show

    aaazzzz.

    karthik

  • karthikeyan (12/12/2008)


    yes...it should work..

    because it should use the ascii value..so ascii value for b is always greater than ascii value of a...so it will show the first part...

    but in my case....

    what is the ascii value for 'karthik' ? because it has 7 characters...how it will calculate it internally ?

    Like this:

    Compare the first character on the left and on the right side. If ascii value left > ascii value right (or right character is empty) then left > right. If characters are the same - move to the next character.

  • Having an index or an ordered set of data makes no difference in the results returned. It only makes a difference in the time it takes to return the results.

    If there is an index, or if it's ordered, it doesn't have to do a full table scan to find out which values are greater than the search criteria. It can basically go right to the criteria and output everything after it.

    If there is no index and it's unordered, it has to one by one examine every value and compare it to the search criteria. It evaluates whether it is greater than the search criteria. If it is, it outputs it. If it isn't it doesn't.

    The presence or absence of an index will not change the resulting query output.

    - Cindy

  • karthikeyan (12/12/2008)


    yes...it should work..

    because it should use the ascii value..so ascii value for b is always greater than ascii value of a...so it will show the first part...

    but in my case....

    what is the ascii value for 'karthik' ? because it has 7 characters...how it will calculate it internally ?

    ascii value 'karthik' = 107 97 114 116 104 105 107

    ascii value 'Karthik' = 75 97 114 116 104 105 107

    http://www.easycalculation.com/ascii-hex.php Google is a beautiful thing...

  • karthikeyan (12/12/2008)


    ok.

    but if we have unordered data...what will happen ?

    you sample data has ordered, so we no need to worry about the result...

    i think we can use ORDERBY clause...but again if we have more than 7000000, i am sure it leads to performance issue.

    The ORDER BY orders the output, it has nothing to do with the filter. As an extra step, it's more likely to reduce performance.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Karthik,

    The WHERE clause has got nothing to do with ORDER BY.

    ORDER BY just sorts the results after the WHERE clause has selected what you want.

    The physical order of the rows in the table doesn't matter either.

    An INDEX doesn't matter as all it does is (maybe) speed up the SELECT process.

    The only thing that matters is that you are SELECTing rows where name > 'karthik'

    and that returns

    ravi

    kuhan

    Cheers,

    Peter

  • Hi Karthik,

    The WHERE cluase is what filters the rows that get returned by your query.

    It doesn't care about the physical order of the rows in the table.

    The ORDER BY clause is applied after the filtering by the WHERE clause.

    Indexes don't matter. They would only speed up the filtering (maybe).

    Cheers,

    Peter

Viewing 7 posts - 16 through 21 (of 21 total)

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