count a column

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: count a column

  1. #1
    newtoo Guest

    Default count a column

    Okay, <BR>i would liket to select all things from my query and i would like to count all of a specific column. how do i do both in one stmt.<BR>this doesn&#039t seem to work<BR>select *, count(CKTSTAT)<BR>from allclo<BR>where state = &#039md&#039<BR>

  2. #2
    MG Guest

    Default RE: count a column

    You will need to execute two queries. <BR>First<BR><BR>select count(id) as cnt from allclo where state=&#039md&#039<BR><BR>open it up, get the cnt then close it<BR><BR>Second<BR>select * from allclo where state=&#039md&#039<BR>

  3. #3
    Sateesh Guest

    Default It is possible

    use this stmt<BR>select *, (select count(CKTSTAT) from allclo) from allclo<BR><BR>but it will repeate the same count for all the rows in the first select stmt<BR>

  4. #4
    newtoo Guest

    Default RE: count a column

    great,<BR>what do you mean by closing???<BR>thanks

  5. #5
    Sateesh Guest

    Default You can do it in a single statement

    instead of hitting the database twice you can do it in a single stmt

  6. #6
    Join Date
    Dec 1969
    Los Angeles, CA

    Default WOW......Why complicate things

    &#062;select * from allclo where state=&#039md&#039<BR>will return x nember of records<BR><BR>&#062;select count(id) as cnt from allclo where state=&#039md&#039<BR>this will also return x <BR><BR>right.....<BR><BR>so why not just select like one would normally do and then get the number of records in the front end<BR><BR> ...yada yada yada<BR><BR>then <BR>arrData = rec.getrows<BR><BR>number of records will then be ubound(arrData)<BR><BR>this will be easier than opening 2 recordsets.

  7. #7
    Join Date
    Dec 1969

    Default RE: It is possible

    cool,<BR>so does this hurt the system less than doing 2 separate queries?<BR>

  8. #8
    MG Guest

    Default RE: WOW......Why complicate things

    I figured it could be done that way but was not sure of the syntax.

  9. #9
    new too Guest


    great,<BR>i figure there was a way to count record sets but i couldn&#039t figure it out so i resorted back to the sql count.<BR>thanks.

  10. #10
    Sateesh Guest

    Default RE: It is possible

    offcource it improves the performance, instead of hitting the database server twice u hit is once, especially when the database server is seperate from that of the iis server the peformance matters

Posting Permissions

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