I have a select statement that shows a set of totals in a table by timestamp and past year / half.
However, I'm having trouble adding a way to show the total number of records. Can I do it without subquery? Or would I have to add a column to the result and make a running total?
I have so far:
CHOOSE SUM (x) total FROM ( SELECT YEAR (TimeStamp) Year, 1 + MONTH (TimeStamp) / 7 Half, Number (*), Zt FROM table1 WO Row1 = & # 39; Blah & # 39; GROUP BY YEAR (timestamp), 1 + MONTH (timestamp) / 7 ORDER AFTER YEAR DESC, half ASC ) x
But it is not analyzed properly. I am sure something is wrong with my syntax, but I am not sure how to display a sum at the end or anywhere, even if this is the result.
I have seen the question percent to total in PostgreSQL without subquery, but I do not want to scan the table twice and I do not yet understand the window functions, but I have tried not to get them working here.