title: ISNULL function combined with TOP 1 command
body: <p>I'm currently creating an statistic report using jaspersoft iReport 5.6.0 and MSSQL Server v17 in order to check on the malfunctioning sql.</p>
  
  <p>In that report some statements (like "ALBRabatt") are part of calculations so they are multiplied, divided and so on.</p>
  
  <p>So the result of this statement cannot be "NULL", hence I'm trying to solve this using ISNULL.</p>
  
  <p>But i have trouble with following statement:</p>
  
  <pre><code>ISNULL  
  (  
        (  
          select top 1 rabatt  
          from artikellieferant  
          left join artikel on artikel.artikel=artikellieferant.artikel  
          where artikel.artikel=artikellieferant.artikel   
          order by artikellieferant.gueltigvon asc  
      ),  
      0  
      ) AS ALBRabatt
  </code></pre>
  
  <p>Error Message:</p>
  
  <blockquote>
    <p><em>Msg 156, Level 15, State 1, Line 7
        Incorrect syntax near the keyword 'order'.</em></p>
  </blockquote>
  
  <p>Please help me to fix this.</p>