The following example creates a table, TableStatistics, and inserts into it the total number of sales orders per year as stored
in the SalesOrders table:
CREATE TABLE TableStatistics (
ID INTEGER NOT NULL DEFAULT AUTOINCREMENT,
Year INT,
NumberOrders INT );
INSERT INTO TableStatistics ( Year, NumberOrders )
SELECT DATEPART( Year, OrderDate ), COUNT(*)
FROM SalesOrders
GROUP BY DATEPART( Year, OrderDate );