title: Sql query to create a calculated field
body: <p>I have a database table like this:<br>
  <img src="https://i.stack.imgur.com/QayqP.png" alt="enter image description here"><br>
  I hope I can explain this well, so you can understand.</p>
  
  <p>I want to calculate how many hours each employee has worked.<br>
  For example for "Arjeta Domi" we have Cell(2,3) - Cell(3,3) + Cell(4,3) + Cell(5,3), making the difference of each logOut time with Login time.</p>
  
  <p><img src="https://i.stack.imgur.com/VnRrX.png" alt="enter image description here"></p>
  
  <p>The final table that I want will have these columns: <code>CardNo</code>, <code>UserName</code>, <code>Date</code>, <code>PauseTime</code>, <code>WorkTime</code></p>
  
  <p>I tried this query: taken from the <a href="https://stackoverflow.com/questions/25929155/sql-query-with-inner-select">duplicate</a></p>
  
  <pre><code>SELECT DISTINCT
    [Card NO], 
    [User Name],  
    (
      SELECT
        MIN(DateTime) AS [Enter Time], 
        MAX(DateTime) AS [Exit Time], 
        MAX(DateTime) - MIN(DateTime) AS [Inside Hours] 
      FROM
        ExcelData
    ) 
  FROM
    ExcelData
  GROUP BY
    [Card NO], [User Name], DateTime
  </code></pre>
  
  <p>The <code>DateTime</code> Column is of type <code>String</code>, not <code>DateTime</code>.
  I am working with MS Access Database.</p>