Unique Records in asp

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Unique Records in asp

    Hi,

    How can I count only unique records in a recordset? (sql server 7.0).

    When I do a select query for an asp page, I may have more than 1 record with
    the same (for example) STATEMENTID. When I count the records Iwant to
    register only 1 record increment for each unique STATEMENTID.

    How can I do this?

    Thanks in advance.

    Miguel.


    Miguel Orrego Guest

  2. Similar Questions and Discussions

    1. Unique Form inserting into many tables using unique id
      I have a Registration Form that have 3 steps. The data could be inserted into many (4) tables. Some data corresponding to a one table (the main or...
    2. Unique Record
      I've forgotten how to do this. I have multiple UPC codes in a document, but I just want to write each of them once when I output. What's the...
    3. Problem updating unique mutiple records
      What I need to do: Create an output form where users can update/delete a particular entry in my database. For example: Entry 1...
    4. Do I need INDEXes when a UNIQUE has been set?
      Having re-jigged the UNIQUE to the proper syntax it does do what I want - wahey!! Just to finish this off here is my final table DDL: CREATE...
    5. unique id
      Hi there! What's the best way to create uids (unique ids) even when runnig at exactly same time (microseconds)? is this enough ??? $r =...
  3. #2

    Default Re: Unique Records in asp

    If you're already looping through every row, then you can keep a counter
    yourself.


    stCount = 0
    stid = -500000
    do while not rs.eof
    if rs("statementid") <> stid then
    stid = rs("statementid")
    stCount = stCount + 1
    end if
    ...
    rs.movenext
    loop


    Or, you can run a different query for the count:

    SELECT COUNT(*) FROM (SELECT DISTINCT statementid FROM table GROUP BY
    statementid)

    In SQL Server 2000, I believe you can do SELECT COUNT(DISTINCT statementid)
    FROM table






    "Miguel Orrego" <miguel@stressedmonkey.net-nospam> wrote in message
    news:3f005bde$0$18490$cc9e4d1f@news.dial.pipex.com ...
    > Hi,
    >
    > How can I count only unique records in a recordset? (sql server 7.0).
    >
    > When I do a select query for an asp page, I may have more than 1 record
    with
    > the same (for example) STATEMENTID. When I count the records Iwant to
    > register only 1 record increment for each unique STATEMENTID.
    >
    > How can I do this?
    >
    > Thanks in advance.
    >
    > Miguel.
    >
    >

    Aaron Bertrand - MVP Guest

  4. #3

    Default Re: Unique Records in asp

    "Miguel Orrego" <miguel@stressedmonkey.net-nospam> wrote in message
    news:3f005bde$0$18490$cc9e4d1f@news.dial.pipex.com ...
    > Hi,
    >
    > How can I count only unique records in a recordset? (sql server 7.0).
    >
    > When I do a select query for an asp page, I may have more than 1 record
    with
    > the same (for example) STATEMENTID. When I count the records Iwant to
    > register only 1 record increment for each unique STATEMENTID.
    >
    > How can I do this?
    >
    > Thanks in advance.
    >
    > Miguel.
    >
    >
    SELECT DISTINCT STATEMENTID from ...

    This will return only record for each unique statementid value. It will
    only work for records which are identical.

    If you use

    select distinct statementid, anothercolumn from ...

    and there are two records with the same value of statementid,but a
    different value in anothercolumn then both will be returned.

    --
    John Blessing
    [url]http://www.LbeHelpdesk.com[/url] - Help Desk software at affordable prices
    [url]http://www.free-helpdesk.com[/url] - Completely free help desk software !
    [url]http://www.lbetoolbox.com[/url] - Remove Duplicates from MS Outlook
    [url]http://www.lbesync.com[/url] - Synchronize two Outlook Personal Folders

    John Blessing Guest

  5. #4

    Default Re: Unique Records in asp

    select count( distinct STATEMENTID ) from ...

    --
    Mark Schupp
    --
    Head of Development
    Integrity eLearning
    Online Learning Solutions Provider
    [email]mschupp@ielearning.com[/email]
    [url]http://www.ielearning.com[/url]
    714.637.9480 x17


    "Miguel Orrego" <miguel@stressedmonkey.net-nospam> wrote in message
    news:3f005bde$0$18490$cc9e4d1f@news.dial.pipex.com ...
    > Hi,
    >
    > How can I count only unique records in a recordset? (sql server 7.0).
    >
    > When I do a select query for an asp page, I may have more than 1 record
    with
    > the same (for example) STATEMENTID. When I count the records Iwant to
    > register only 1 record increment for each unique STATEMENTID.
    >
    > How can I do this?
    >
    > Thanks in advance.
    >
    > Miguel.
    >
    >

    Mark Schupp Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139