Gets list of years and total of posts per year from a table, by using date column, passing table name and column name with date to summarize by.
Returns Year{{$C$}}45{{$R$}}2007{{$C$}}44{{$R$}}...

Function Posts_per_Year(TableName, DateColumn)
 FSQL = "SELECT yoyo, SUM(coco1) AS coco FROM (SELECT YEAR(" & DateColumn & ") AS yoyo, COUNT(*) AS coco1 FROM " & TableName & " GROUP BY " & DateColumn & ") AS derivedtbl_1 GROUP BY yoyo ORDER BY yoyo DESC"
 set recF = connection.execute(fSQL)
 Do Until recF.Eof
  GGe = GGe & trim(recF("yoyo")) & "{{$C$}}" & trim(recF("coco")) & "{{$R$}}"
 Posts_per_Year = GGe
End Function


TableName, DateColumn

Views 145 Downloads 60

Perm link