473,395 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

counting question

i have been searching online for a few days now, and I can't seem to
find the answer for what I am looking for, maybe I just don't know how
to phrase it properly for the search engines...

at any rate say I have a database with the following records
john
david
john
john
al
ed
tom
tom
what I am looking for a is tutorial/lesson that eplains on how i can
write an asp script that will autmatically count these for me and return
the following:

john 3
tom 2
david 1
al 1
ed 1

(total the amount of times the name shows up and sort it in descending order

now I know I can do

"Select Count(*) AS process FROM table WHERE name='john';"

and this will tell me that john shows up 3 times, but I don't want to
have to code this for everyname, so I am looking for a
lesson/tuturial/example that will look at the name colum, figure out all
the names which show up and then count them before sorting them out

i think you can see why i am having a problem searching for this...

if anyone can point me towards a link that helps to get me going on
this, or even the correct phrase to use when searching for it would help
also, please keep in mind i'm not a programmer i'm just learning this
for my own interest which is why i would prefer to find a
lesson/tutorial that explains what is happening

thanks
Jul 22 '05 #1
6 1163
Not sure this is the exact syntax but:

select personname, count(personname) from yourtable group by personname

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"C White" <cw****@theatomicmoose.ca> wrote in message
news:rf********************@rogers.com...
i have been searching online for a few days now, and I can't seem to find
the answer for what I am looking for, maybe I just don't know how to phrase
it properly for the search engines...

at any rate say I have a database with the following records
john
david
john
john
al
ed
tom
tom
what I am looking for a is tutorial/lesson that eplains on how i can write
an asp script that will autmatically count these for me and return the
following:

john 3
tom 2
david 1
al 1
ed 1

(total the amount of times the name shows up and sort it in descending
order

now I know I can do

"Select Count(*) AS process FROM table WHERE name='john';"

and this will tell me that john shows up 3 times, but I don't want to have
to code this for everyname, so I am looking for a lesson/tuturial/example
that will look at the name colum, figure out all the names which show up
and then count them before sorting them out

i think you can see why i am having a problem searching for this...

if anyone can point me towards a link that helps to get me going on this,
or even the correct phrase to use when searching for it would help also,
please keep in mind i'm not a programmer i'm just learning this for my own
interest which is why i would prefer to find a lesson/tutorial that
explains what is happening

thanks

Jul 22 '05 #2
Mark Schupp wrote:
Not sure this is the exact syntax but:

select personname, count(personname) from yourtable group by personname

that was great!!! it was so simple yet i had a hard time figuring it out
until you posted your sample, what i did was

select Name, count(Name) AS namecount from Table group by Name

and it worked

thanks!!!!
Jul 22 '05 #3

"C White" <cw****@theatomicmoose.ca> wrote in message
news:rf********************@rogers.com...
i have been searching online for a few days now, and I can't seem to
find the answer for what I am looking for, maybe I just don't know how
to phrase it properly for the search engines...

at any rate say I have a database with the following records
john
david
john
john
al
ed
tom
tom
what I am looking for a is tutorial/lesson that eplains on how i can
write an asp script that will autmatically count these for me and return
the following:

john 3
tom 2
david 1
al 1
ed 1

(total the amount of times the name shows up and sort it in descending order
now I know I can do

"Select Count(*) AS process FROM table WHERE name='john';"

and this will tell me that john shows up 3 times, but I don't want to
have to code this for everyname, so I am looking for a
lesson/tuturial/example that will look at the name colum, figure out all
the names which show up and then count them before sorting them out

i think you can see why i am having a problem searching for this...

if anyone can point me towards a link that helps to get me going on
this, or even the correct phrase to use when searching for it would help
also, please keep in mind i'm not a programmer i'm just learning this
for my own interest which is why i would prefer to find a
lesson/tutorial that explains what is happening

thanks


If you throw an "OREDR BY " clause into the SQL, it would make things go a
lot easier (Order By name)
then just treat it like a simple control-break

psuedo-code for ya......
set counter to 0
read a name into a hold field (primer read)
'//**then start the loop
do while not rs.eof
read next name
if its the same as in the hold field
increment the counter
else
print the name and the value of the counter
set counter to 0
set the hold filed to the new name
end if
Loop

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.807 / Virus Database: 549 - Release Date: 12/7/2004
Jul 22 '05 #4

"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:TO***************@bignews6.bellsouth.net...

psuedo-code for ya......
set counter to 0
read a name into a hold field (primer read)
'//**then start the loop
do while not rs.eof
read next name
if its the same as in the hold field
increment the counter
else
print the name and the value of the counter
set counter to 0
set the hold filed to the new name
end if
Loop


This is a joke, right?
Jul 22 '05 #5

"Des Perado" <de*@per.ado> wrote in message
news:32*************@individual.net...

"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:TO***************@bignews6.bellsouth.net...

psuedo-code for ya......
set counter to 0
read a name into a hold field (primer read)
'//**then start the loop
do while not rs.eof
read next name
if its the same as in the hold field
increment the counter
else
print the name and the value of the counter
set counter to 0
set the hold filed to the new name
end if
Loop


This is a joke, right?


No - but I liked Mark's solution better, too.
Thanks for the kind words

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004
Jul 22 '05 #6
Hal Rosser wrote:
"Des Perado" <de*@per.ado> wrote in message
news:32*************@individual.net...
"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:TO***************@bignews6.bellsouth.net. ..
psuedo-code for ya......
set counter to 0
read a name into a hold field (primer read)
'//**then start the loop
do while not rs.eof
read next name
if its the same as in the hold field
increment the counter
else
print the name and the value of the counter
set counter to 0
set the hold filed to the new name
end if
Loop


This is a joke, right?

No - but I liked Mark's solution better, too.
Thanks for the kind words

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.817 / Virus Database: 555 - Release Date: 12/15/2004

It's all good to me :)
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage...
1
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage...
18
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other...
1
by: j | last post by:
Hi, I've been trying to do line/character counts on documents that are being uploaded. As well as the "counting" I also have to remove certain sections from the file. So, firstly I was working...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
4
by: aaronfude | last post by:
Hi, Please consider the following class (it's not really my class, but it's a good example for my question): class Vector { int myN; double *myX; Vector(int n) : myN(n), myX(new double) { }...
10
by: cj | last post by:
I'm writing a TCP/IP server app that will have many simultaneous connections. The main thread listens for new connections and starts a thread to handle each requested connection. These are short...
4
by: Dado | last post by:
I have a next situation with the textbox field: A - B = C 1. How to fill the A fill with the data from my previous recordset ? Can I do it with the expression builder ? 2. I want that every...
3
by: Nhd | last post by:
I have a question which involves reading from cin and counting the number of words read until the end of file(eof). The question is as follows: Words are delimited by white spaces (blanks,...
0
by: Andreas Huesgen | last post by:
Hello, I have a question refering python's reference counting/garbage collection in combination with thrown exceptions. I'm very new to this mailinglist, so I hope, that this question has not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.