Ask a Question related to ASP Database, Design and Development.
-
Miguel Orrego #1
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
-
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... -
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... -
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... -
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... -
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 =... -
Aaron Bertrand - MVP #2
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 ...with> 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> 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
-
John Blessing #3
Re: Unique Records in asp
"Miguel Orrego" <miguel@stressedmonkey.net-nospam> wrote in message
news:3f005bde$0$18490$cc9e4d1f@news.dial.pipex.com ...with> 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 recordSELECT DISTINCT STATEMENTID from ...> 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.
>
>
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
-
Mark Schupp #4
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 ...with> 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> 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



Reply With Quote

