title: how to order 2 SQL Fields in asc and desc dynamically
body: <p>I want to Order a SQL Select Query where there's 2 fields that are in the order by. I then need to decide if one is Descending and the other as Ascending. How is this done</p>
  
  <p>I want something like:</p>
  
  <pre><code>Select * from Customer
  Order By Date @asc_or_Desc_date, Name @asc_or_Desc_name
  </code></pre>
  
  <p>Anyone got any ideas?</p>
  
  <p>I have tried this but it seems to fail</p>
  
  <pre><code>SELECT 
  
      Customer_ID,                        
      Name,                               
      Age                                         
  
  FROM #Customer
  ORDER BY 
  
      CASE WHEN @fieldSort ='Name'
          THEN ROW_NUMBER() over (order by Name) * 
              case when @directionOfSort = 'A' 
                  THEN 1 ELSE -1 END,
               ROW_NUMBER() over (order by Age) * 
              case when @directionOfSort = 'A' 
                  THEN 1 ELSE -1 END,
          END
  </code></pre>
  
  <p>Anyone know how to sort this?</p>