using 'Compute by' clause in recordset

Results 1 to 2 of 2

Thread: using 'Compute by' clause in recordset

  1. #1
    Suhail Guest

    Default using 'Compute by' clause in recordset

    I would like to know, how do I fetch the result of Compute by clause in a recordset? The output must show detail rows as well as summary rows. <BR>I&#039ve written the query that has a recordset that uses a query having compute by clause. When I execute that ASP page, it shows detail rows but breaks the loop soon after it encounters first summary result of compute by. My code is as under...<BR><BR>strSQL = "select zone,state,city,sales "<BR>strSQL = strSQL & "from tmp_sk "<BR>strSQL = strSQL & "order by zone,state,city "<BR>strSQL = strSQL & "compute sum(sales) by zone,state,city "<BR>strSQL = strSQL & "compute sum(sales) "<BR><BR>rs.Open strSQL,con,adOpenStatic,adLockReadOnly <BR>if rs.recordcount = 0 then<BR> destroyall()<BR> response.write "No records found"<BR> destroyall()<BR>end if <BR><BR>while not rs.EOF<BR> response.write "zone :" & rs("zone")<BR> response.write "State :" & rs("State")<BR> response.write "City :" & rs("City")<BR> response.write "Sales :" & rs("Sales") & "<BR>"<BR> rs.movenext<BR>wend<BR><BR>If you have any idea of showing the summary values, please do helpout.<BR><BR>Thanks<BR><BR>Suhail

  2. #2
    Join Date
    Dec 1969

    Default RE: using 'Compute by' clause in recordset

    To get the summary results, you have to get the next recordset after retrieving the first -- compute will cause the result set to be in two recordsets, your initial "full listing" recordset, and then the "computed" recordset. The problem with this approach is that recordcount does not always function properly. <BR><BR>after your wend put in:<BR><BR>set rs = rs.nextrecordset<BR><BR>while not rs.eof <BR>...<BR>wend

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts