title: correct way for using joins when use len() sql server
body: <p>I need to <strong>join</strong> one or two tables. One table have salary field. So i make some calculations also if the field is null means it returns 0. So I use <strong>len()</strong>. But i can't access the correct values. when i use join before <strong>len()</strong> condition i have a result. But result id column comes unorder like <strong>1,4,46,89,</strong>...something like that. I don't know why.</p>
  
  <p><strong>My query is,</strong></p>
  
  <pre><code> CAST(SUBSTRING(CAST(o.Budget AS VARCHAR(50)), 0, PATINDEX('%laks%', o.Budget))*100000
  
   + SUBSTRING(CAST(o.Budget AS VARCHAR(50)), PATINDEX('%laks%', o.Budget) + 4, 
      patindex('%Thousands%', o.Budget) - PATINDEX('%laks%', o.Budget) - 4)* 1000 AS   VARCHAR(50))+')'
  
      FROM requirementsdetailsfororganization o 
      right Join Requirementsregistereddetails AS r ON r.registereddate=r.registereddate
      left join Requirement_Contact_Details as rc ON rc.RequirementID=o.requirementId
      **where len(o.Budget)&lt;&gt;0** 
  </code></pre>
  
  <p>In the above code where i starred this condition i used. But why it shows this types of values. </p>
  
  <p><strong>MY output:</strong></p>
  
  <p>Insert into jobs(<strong>1</strong>,85000)</p>
  
  <p>Insert into jobs(<strong>3</strong>,205000)</p>
  
  <p>Insert into jobs(<strong>4</strong>,0(when null))</p>
  
  <p>Insert into jobs(<strong>16</strong>,145000)</p>
  
  <p>Insert into jobs(<strong>18</strong>,110000)</p>
  
  <p>In the previous result, what i bold the values are Id. It is unordered and some values are missed within the range of values when i use len()</p>
  
  <p>Any one suggest me my issue?</p>