You'd have to use a join on a subquery (don't know if Access supports this
directly, in which case you'd have to use a stored query for the subquery):

Select C.MyCount, T.*
>From MyTable as T
Inner Join (Select Count(*) as MyCount From MyTable) as C

Note that there is no ON clause.  Since there is only one row returned from
the subquery, the Cartesian product is actually what we are looking for.

But I have to agree with Chris - Why would you want the count on every row?
If nothing else, this wastes network bandwidth.  You can either return the
count as the return value from the stored procedure, or simply have two
separate queries - one for the count and one for the data.  A count of all
records in a table should be relatively quick.  If you have complex and
non-optimizable criteria in the query, consider selecting into a temporary
table (SQL Server) and obtain the count (and subsequently the data) from it.

HTH,
Tore.

-----Original Message-----
From: Steve Abaffy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 09, 2002 10:42 AM
To: ActiveServerPages
Subject: OT: Quick SQL Query Question


Hello,

How do I write a query that will return all the rows in a table with the
addition of the count of those rows?
Something like

Select Count(*),* From table

Thanks in Advandce



---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to