Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to group the sums

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi

I have a table:

Transit Name AssetType
8 John Monitor
8 Smith Monitor
9 Anna Server
9 David Server

What i want to put into the HTML table is:

Transit Monitor Server
8 2 0
9 0 2


Please help me with the code

Thanks
 
hmm

well I'll set the connection etc. aside for a minute and give you a example of the SQL statement. it will actually be easier then it sounds,
<%
SQLtxt = &quot;SELECT COUNT(*) FROM tablename WHERE AssetType = 'Server'&quot;
conn.execute(SQLtxt)
%>
that's it, the same with the other field
this with the table you have above will output a value of 2


A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Heres one that should return all of the information grouped similar to what you had above:

SQLtxt = &quot;SELECT COUNT(Name) as numEntries, AssetType FROM tablename GROUP BY AssetType ORDER BY AssetType&quot;

That will return a recordset that looks like:
2 Monitor
2 Server

etc...

-Tarwn &quot;If you eat a live toad first thing in the morning, nothing worse will happen all day long.&quot; - California saying
&quot;To you or the toad&quot; - Niven's restatement of California saying
&quot;-well most of the time anyway...&quot; - programmers caveat to Niven's restatement of California saying
(The Wiz Biz - Ri
 
Actually I wouldn't even had remembered the correct way to do that if I hadn't used it a couple days ago :p
I'm out of town right now so i am enjoying a very rare moemnt of actually being able to get on the forum :)
-Tarwn &quot;If you eat a live toad first thing in the morning, nothing worse will happen all day long.&quot; - California saying
&quot;To you or the toad&quot; - Niven's restatement of California saying
&quot;-well most of the time anyway...&quot; - programmers caveat to Niven's restatement of California saying
(The Wiz Biz - Ri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top