sum recordsets -please help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jasone
    New Member
    • Mar 2007
    • 66

    sum recordsets -please help

    hi,

    i suppose this is a pretty simple thing, i am unsure how to proceed though.

    i have 2 recordsets counting items ifrom 2 tables how would i then add these recordsets together.

    the recordsets ive used are shown below

    Code:
    set rs1=cn.execute ("Select count(*) as cardifarrivals from tbl_flight_details WHERE arriving_airport ='cardiff'") 
    
    set rs=cn.execute ("Select count(*) as cardiffdepartures from tbl_flight_depts")
    these then give results of say 3 and 5 i know want to add these together to give the result in a variable,

    or is it possible to select count on 2 tables, and store this in another recordset?
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by jasone
    hi,

    i suppose this is a pretty simple thing, i am unsure how to proceed though.

    i have 2 recordsets counting items ifrom 2 tables how would i then add these recordsets together.

    the recordsets ive used are shown below

    Code:
    set rs1=cn.execute ("Select count(*) as cardifarrivals from tbl_flight_details WHERE arriving_airport ='cardiff'") 
    
    set rs=cn.execute ("Select count(*) as cardiffdepartures from tbl_flight_depts")
    these then give results of say 3 and 5 i know want to add these together to give the result in a variable,

    or is it possible to select count on 2 tables, and store this in another recordset?
    So what problem are you having?

    Just add them together.

    Code:
    dim strTotal
    strTotal = rs1("cardifarrivals") + rs("cardiffdepartures")

    Comment

    • jeffstl
      Recognized Expert Contributor
      • Feb 2008
      • 432

      #3
      If that doesn't work you might have to type cast the values with cint() or something.

      cint(rs1("cardi farrivals")) + cint(rs("etc"))

      Comment

      Working...