title: C# SQL to Linq - translation
body: <p>I have a table with transactions, similar to:</p>
  
  <pre><code>--REQUEST_ID----ITEM_ID----ITEM_STATUS_CD----EXECUTION_DTTM       
       1             1            1          2016-08-29 12:36:07.000   
       1             2            0          2016-08-29 12:37:07.000
       2             3            5          2016-08-29 13:37:07.000
       2             4            1          2016-08-29 15:37:07.000
       2             5            10         2016-08-29 15:41:07.000
       3             6            0          2016-08-29 15:41:07.000
  </code></pre>
  
  <p>What i want is at table showing how many success/warning/Error in % with endtime of the latest transaction in the Request_ID:</p>
  
  <pre><code>--REQUEST_ID--Transactions----------EndTime----------Success----Warning----Error     
       1               2        2016-08-29 12:37:07.000   50         50         0
       2               3        2016-08-29 15:41:07.000    0         33         66
       3               1        2016-08-29 15:41:07.000   100         0         0
  </code></pre>
  
  <p>I have the table that I want by the following slq, but I dont know how to do it in linq(C#)....Anyone? </p>
  
  <pre><code>SELECT distinct t1.[REQUEST_ID], 
                t2.Transactions,
                t2.EndTime,
                t2.Success,
                t2.Warning,
                t2.Error
            FROM [dbo].[jp_R_ITEM] t1 inner join(
            select top(100) max([EXECUTION_DTTM]) EndTime,  REQUEST_ID,
                   count([ITEM_ID]) as Transactions,
                   coalesce(count(case when [ITEM_STATUS_CD] = 0 then 1 end), 0) * 100 / count([ITEM_ID]) as Success,
                   coalesce(count(case when [ITEM_STATUS_CD] = 1 then 1 end), 0) * 100 / count([ITEM_ID]) as Warning,
                   coalesce(count(case when [ITEM_STATUS_CD] &gt; 1 then 1 end), 0) * 100 / count([ITEM_ID]) as Error
              from  [dbo].[jp_R_ITEM] group by REQUEST_ID order by REQUEST_ID desc) t2 on t1.[REQUEST_ID] = t2.REQUEST_ID and t1.[EXECUTION_DTTM] = t2.EndTime
  </code></pre>