title: Get MB used and row count of filtered records of all tables
body: <p>I have a problem with a query in SQL Server.
  I want to get the total count and the used disk space of records created in year 2020 (I have a column <code>SysDateCreate</code> in all tables) for each table.
  I want a 'table result' like this:</p>
  <pre><code>| Year | TableName | TotalRowCont | Total_MB |
  </code></pre>
  <p>And I wrote this query:</p>
  <pre><code>SELECT
      NULL AS Year,
      sys.tables.name AS TableName, 
      MAX(sys.partitions.rows) AS TotalRowCount,
      CAST(ROUND((SUM(sys.allocation_units.used_pages) / 128.00), 2) AS NUMERIC(36, 2)) AS Used_Mb,
      CAST(ROUND((SUM(sys.allocation_units.total_pages) - SUM(sys.allocation_units.used_pages)) / 128.00, 2) AS NUMERIC(36, 2)) AS Unused_Mb,
      CAST(ROUND((SUM(sys.allocation_units.total_pages) / 128.00), 2) AS NUMERIC(36, 2)) AS Total_Mb
  FROM sys.tables
  INNER JOIN sys.indexes ON sys.tables.object_id = sys.indexes.object_id
  INNER JOIN sys.partitions ON sys.indexes.object_id = sys.partitions.object_id AND sys.indexes.index_id = sys.partitions.index_id
  INNER JOIN sys.allocation_units ON sys.partitions.partition_id = sys.allocation_units.container_id
  WHERE sys.tables.name LIKE 'Tb%' 
  GROUP BY sys.tables.name
  ORDER BY sys.tables.name
  </code></pre>
  <p>How can I filter/group by year?</p>
  <p>Thanks in advance.</p>