title: SQL Server Row_number in odd/even number?
body: <p>I have a question about querying accounting data.</p>
  
  <p>For example, the sample data is show like below</p>
  
  <p>Table: <strong>Table_Test</strong></p>
  
  <pre><code>Date        Amount  
  2013-01-01  12.00
  2013-01-02  13.00
  </code></pre>
  
  <p>The output should be like this:</p>
  
  <pre><code>Date        Account        Debit    Credit
  2013-01-01  Abccompany     12.00
  2013-01-01  Vendorcompany           12.00
  2013-01-02  Abccompany     13.00
  2013-01-02  Vendorcompany           13.00
  </code></pre>
  
  <p>Initially, I was think about using a union statement because may be the output sequece is not very important and the sample sql show like below</p>
  
  <pre><code>Select 
      Date as 'Date', 
      'Abccompany' as 'Account', 
      Amount as 'Debit', 
      '0' as credit
  from Table_Test
  
  union
  
  select
      Date as 'Date', 
      'VendorCompany' as 'Account', 
      '0' as 'Debit', 
      Amount  as credit
  from Table_Test
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Date        Account        Debit    Credit
  2013-01-01  Abccompany     12.00
  2013-01-02  Abccompany     13.00
  2013-01-01  Vendorcompany           12.00
  2013-01-02  Vendorcompany           13.00
  </code></pre>
  
  <p>but it seem after I show the output to my PIC, he mention it was wrong that the sequence is quite important to them.(used to export into their system)</p>
  
  <p>What came out from my mind is using T-Sql to manipulate this that may be provide a flag like IsDebit and possible row_number(odd number in first sql, even number on second sql then union and made some logic on it? Possible?)</p>
  
  <p>Is someone are able to provide me some idea how to deal with this?</p>