title: Where clause with calculated column
body: <p>Hello i want to add a condition here like <code>where Date between ..</code> and <code>SalesPercentage &gt; 50</code> but it salespercentage is not a column in db and its just casted like in the code below. </p>
  
  <p>How can i use it. Thanks in advance.</p>
  
  <pre><code>      var sql = @"SELECT TOP 10 
                      sp.ProductName, 
                      SUM(sp.QtySold) AS QtySold,
                      SUM(r.QtyinPieces) AS StockLimit,                  
                      CAST(    (CAST    (SUM(sp.QtySold) AS FLOAT)     /    CAST(SUM(r.QtyinPieces) AS FLOAT)  ) * 100 AS DECIMAL(8,2)       ) [SalesPercentage]
                  FROM 
                      Sales_productholder sp
                      JOIN Orders_productholder r ON (sp.ProductID = r.ProductID)
  
                  GROUP BY 
                      sp.ProductName, r.ProductID, r.QtyinPieces
                  ORDER BY 
                      SUM(sp.QtySold) DESC";
  </code></pre>
  
  <p>Update: I have combobox that have items like 5,10,20 and i want to use it as parameters for <code>Top 5</code>. But it always result in error <code>Incorrect syntax near TOP</code></p>
  
  <p>Here is what i tried:</p>
  
  <p>SELECT TOP @Top</p>
  
  <pre><code>command.Parameters.AddWithValue("@Top", cboTop.SelectedItem.ToString());
  </code></pre>
  
  <p>and </p>
  
  <pre><code>string topp = cboTop.SelectedItem.ToString();
   command.Parameters.AddWithValue("@Top", topp);
  </code></pre>