Re: Conditional Running Sum



On Sun, 30 Mar 2008 22:55:30 -0700 (PDT), mezzanine1974
<savas_karaduman@xxxxxxxxx> wrote:

Hello Arch,
You are right that i did a mistake in the first line.

your statement CORRECT! <By "between" do you mean inclusive of the
Start date but not the
Finish date?>


It probably can be done in SQL, but I'm not good enough in SQL to do
it. This function works as you requested, however:


Public Function CalcSum(Tdate As Date)
Dim SQL As String
Const StartDate As String = "Sdate"
Const FinishDate As String = "Fdate"
SQL = "Select sum(money) from q1 " & _
"where #" & Tdate & "# >= " & StartDate & _
" AND #" & Tdate & "# < " & FinishDate
CalcSum = CurrentProject.Connection.Execute(SQL).GetString
CalcSum = Left(CalcSum, Len(CalcSum) - 1)
End Function



SELECT SortedDate,
CalcSum(SortedDate) as RunSum
FROM Query1 ;

SortedDate RunSum
1/1/2008 1
2/1/2008 1
3/1/2008 10
4/1/2008 12
5/1/2008

-Arch
.



Relevant Pages

  • Re: Problems with Delete Command
    ... The SQL could get fairly messy if you need to construct it in code, ... ContactID, and WebComID, and create your on-the-fly SQL on that saved query, ... to find the list of ContactIDs from the junction table, ... This is a style/readability thing: if you are going to use string ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Need help with Code Please!!!
    ... posted in response to my last post was some SQL, but this is not the SQL that ... the actual string that gets built at the end of the SQ1 build process. ... The message says Syntax error in query expression ... Dim rs As Recordset 'object ref to qryCompany\USFNumber ...
    (microsoft.public.access.formscoding)
  • RE: Web Part and Access database
    ... I dont know if it is possible to connect to access,but you can download SQL ... Server Error in '/Webparts' Application. ... The connection string specifies a local Sql Server Express instance ... String user, String password, Boolean trusted, String connectionString) ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: INDEXES: BTRIEVE vs EXTFH (cobol)
    ... Bill Bach wrote: ... In SQL, you can specify just about anything, but at the lower MKDE ... the engine has to pick the right Btrieve ... When COBOL needs to find this value, it knows that the key is a string. ...
    (comp.databases.btrieve)
  • Re: INDEXES: BTRIEVE vs EXTFH (cobol)
    ... In SQL, you can specify just about anything, but at the lower MKDE ... the engine has to pick the right Btrieve ... When COBOL needs to find this value, it knows that the key is a string. ...
    (comp.databases.btrieve)