Running Totals and other stuff....
От | Levan, Jerry |
---|---|
Тема | Running Totals and other stuff.... |
Дата | |
Msg-id | 30ECD69B1163C64EA657B3B29D4A938A3B9DFB@FACSTAFF.facultystaff.eku.edu обсуждение исходный текст |
Ответы |
Re: Running Totals and other stuff....
Re: Running Totals and other stuff.... Re: Running Totals and other stuff.... Re: Running Totals and other stuff.... Re: Running Totals and other stuff.... |
Список | pgsql-general |
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Dwindows-1= 252"> Running Totals and other stuff.... Humpfff...Last night I tried posting this and found that<= BR> dynamic IP's are now prevented from posting to the list... Did I miss the announcement? ************************************ Hi, I keep all of my financial data in Postgresql ( 7.4.2). My "Check" register records deposits, withdrawals (as amount) , d= ate, category and other stuff. The following sorta works... SELECT oid, *, (SELECT sum(amount) FROM checks WHERE x.thedate >= =3D thedate ) AS total FROM checks x ORDER BY thedate,oid ; The problem is that all transactions on the same date get the total of all<= BR> transactions for that date, so the resulting table is only "sorta"= ; a running total. If I change the rascal to look like SELECT oid, *, (SELECT sum(amount) FROM checks WHERE x.oid >=3D oi= d ) AS total FROM checks x ORDER BY thedate,oid ; I get the right results, but this relies on the fact the oids in the check table are currently *sorted* (when the table is sorted by thedate) at least it appears that way via a very brief inspection.... I suspect if I deleted a record and added a record the oids would get out of sequence. Is there a slick way to tell if a column (say the oids column) is in "= sorted" order when the table is sorted by date? Assuming the oids get out of wack with respect to the date, is it possible<= BR> to easily construct a table of the checks sorted by date and then "glu= e on" a column of ascending integers so the running total sql statement will function properly? Jerry
В списке pgsql-general по дате отправления: