Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql subtraction (using asp)

Status
Not open for further replies.

jessrs0290

Programmer
May 7, 2004
3
US
Hi, I'm printing out a new total to the screen using asp. the SQL command grabs all records i need and prints them out. That part is fine....so it looks like

Case Number XXXX100CR000012
Party Number 001
Payed By XXXXXX, DAVID C.
Type VICTIM RESTITUTION
Total Amount Owed $15978.6
Date Recieved 3/14/2006
Category CR
Date 11/29/2005
Payment Amount $2598.2

The "Payment amount" is different for each line as people make different payments. I need to subtract the Payment amount from the total amount owed and print that out, while keeping track of it to print out on the next iteration.
I tried to write a query and execute it on the back end, but couldnt get it to work. So I'm trying to do it now on the web page (asp)
Heres my code so far....I just don't know how to subtract the one value from the other, and keep track of it.

The line almost to the bottom
Code:
"<%=(rs("totl_owed_am" - "dllr_am"))%>"
is where the problem obviously is.....

can anyone help??
Code:
<%
totl_owed_am = request.QueryString("totl_owed_am")
 sql = "select * from tbl_probation_offender_payments   where totl_owed_am=" &totl_owed_am
 Set rs = Server.Createobject("adodb.Recordset")
 Set objCmd.ActiveConnection = objConn
 objCmd.CommandText = sql
 objCmd.CommandType = 1
 rs.Open objCmd,,0,3
 if rs.eof then
 response.write("<span class=ten>Record does not exist. Please try again.</span>")
 end if
 Do while NOT rs.eof
 %>
<br> 
 
<table>
  <tr> 
    <td>Case Number</td>
    <td<%=rs("case_num")%></td>
  </tr>
  <tr> 
    <td>Party Number</td>
    <td><%=rs("prty_num")%></td>
  </tr>
  <tr> 
    <td>Payed By</td>
    <td><%=rs("dtl_cmnt")%></td>
  </tr>
  <tr> 
    <td>Type</td>
    <td><%=rs("nm")%></td>
  </tr>
  <tr> 
    <td>Total Amount Owed</td>
    <td>$<%=rs("totl_owed_am")%> </td>
  </tr>
  <tr> 
    <td>Date Recieved</td>
    <td><%=rs("acmp_dt")%> </td>
  </tr>
  <tr> 
    <td>Category</td>
    <td><%=rs("doc_cat")%> </td>
  </tr>
  <tr> 
    <td>Date</td>
    <td>rs<%=rs("doc_dt")%> </td>
  </tr>
  <tr> 
    <td>Payment Amount</td>
    <td><font color="red">$<%=rs("dllr_am")%></font></td>
  </tr>
  <tr>
    <td>New Total</td>
    <td><%=(rs("totl_owed_am" - "dllr_am"))%></td>
  </tr>
</table>

    <%		
      rs.movenext
      loop
      set rs=nothing
    %>
 
Well I figured it out....if anyone's interested in the code let me know.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top