counting records...a lil differently...

Results 1 to 3 of 3

Thread: counting records...a lil differently...

  1. #1
    Join Date
    Dec 1969

    Default counting records...a lil differently...

    OK, so, I have a bunch of records...anywho, this is kind of like a Q&A thing, so questions that haven&#039t been answered appear in this answer page...sounds good, right? right. ok, no, moving on...i want to count all of the reocrds taht are being displayed on this answer would i do that?? i can&#039t do a recordcount because that would count ALL of the records...anyone have any ideas?

  2. #2
    SPG Guest

    Default This might work...

    Expecting that your page is showing all "questions" and "answers" (which should be related but not necessarily) which precludes a simple single-pass query, you could run a second query that looks like<BR><BR>select count(*) from QAtable where answers is NULL<BR><BR>(assuming non-answered questions are null).<BR><BR>Alternately, you could bind that into your initial query by saying [this might work, haven&#039t tested]<BR><BR>select questions, answers, count(select * from QAtable where answer is NULL) as iUnanswered from QAtable ... rest of your query ...<BR><BR>You *should* (if it doesn&#039t toss its cookies at you) have a new iUnanswered category in your recordset which contains the number of unanswered questions.<BR><BR>HiH.<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: counting records...a lil differently...

    SPG&#039s answer seems correct, given the assumptions he has made about what you are doing.<BR><BR>But I am not sure his assumptions are correct.<BR><BR>So follow these questions in order:<BR><BR>When you do the query, are you getting *ALL* records in the table?<BR><BR>If "yes", then: Are you then only displaying only the records where the given question hasn&#039t been answered?<BR><BR>If still "yes", then: Are you doing anything else *ON THIS PAGE* with the records where the question *IS* answered?<BR><BR>If that one is "no", then (and *only* then):<BR><BR>Can you say "oops"?<BR><BR>If "yes" or "no", then...<BR><BR>Why???? Why bother to even *get* the records that you aren&#039t interested in for this particular page?<BR><BR>If your query asked only for the records that had not yet been answered, and if your cursor type is correct, then RecordSet.RecordCount *WILL* be right for the query! (It does *not* give you a count of all records in the table...only of those matching the query.)<BR><BR>AND THEN...<BR><BR>Don&#039t forget about RecordSet.GetRows. Which works with *any* kind of cursor. Pulls all the records into a two-dimensional array. Much faster then RS.MoveNext and all that nonsense. And once you have the records moved into the array, then do<BR>&nbsp;&nbsp;&nbsp;&nbsp;allRows = RS.GetRows<BR>&nbsp;&nbsp;&nbsp;&nbsp;recordCount = UBound( allRows, 2 ) + 1<BR>and you have what you want!<BR><BR><BR>

Posting Permissions

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