title: sql: count in a select with percentages
body: <p>I want to query to return like in the picture, it pretty much explains what i need.:
  <img src="https://i.stack.imgur.com/Xdg4A.png" alt="Database result"></p>
  
  <p>I have my stored proc that returns but just basic:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[p_TargetStatus]
  AS
  BEGIN
         --NOT SURE IF NEEDED
      Declare @OnTime float
      Declare @Overdue float
      Declare @AllON float
      Declare @AllOV float
      Declare @AnswON float
      Declare @AnswOV float
         --END NOT SURE IF NEEDED
  
      SET NOCOUNT ON;
      IF OBJECT_ID('#tmp1') IS NOT NULL
      DROP TABLE #tmp1
  
  
      CREATE TABLE #tmp1 
      (
          AUD_ID BIGINT,
          RowCounter BIGINT,
          DistinctCounter BIGINT,
          NACounter BIGINT,
          Total BIGINT,
          [Status] VARCHAR(MAX)
      )
  
      INSERT INTO #tmp1 EXEC [p_GetCompleteIncompleteNaOverviewSCORE] 
      --NOT SURE IF NEEDED
      Set @OnTime = (Select Count([Status])
      From #tmp1
      Where [Status] = 'OPEN')
  
      Set @AllON = (SELECT COUNT([Status])
      From #tmp1)
  
      SET @AnswON  = @OnTime/@AnswON
  
      Set @Overdue = (Select Count([Status])
      From #tmp1
      Where [Status] = 'CLOSED')
  
      Set @AllOV = (SELECT COUNT([Status])
      From #tmp1)
  
      SET @AnswOV  = @Overdue/@AllOV
         --END NOT SURE IF NEEDED
  
      SELECT COUNT(*) AS [Count],[Target Status] AS TargetStatus
      FROM (
      SELECT CASE WHEN CONVERT(DATETIME,CONVERT(CHAR(10),DATEADD(DAY,0,t2.AUD_TargetDate), 101)) &lt; CONVERT(DATETIME,CONVERT(CHAR(10),DATEADD(DAY,0,GETDATE()), 101))
              THEN 'Over Due' 
              ELSE 'On Time' END AS [Target Status]
              FROM #tmp1 t1 INNER JOIN dbo.Audit t2
              ON t1.AUD_ID = t2.AUD_ID
              WHERE t1.[Status] = 'Open') DER
      GROUP BY [Target Status]
  
  END 
  GO
  </code></pre>
  
  <p>I have tried but failed a bit. The concatination I can figure out but the percentage seems wierd to me?</p>