#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Counting instances in field


    Hi

    I'm relatively new to asp so forgive me if this is a simple thing i should already know!

    I need to find out how many instances of things there are in a field in my DB.

    I can do it individually if i know what the instance is but on this one i need to be able to list all the distinct entries in the field and the amount of times they appear. I'm hoping this can be done as there are hundreds of distinct entries.


    any help is much appreciated.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    Please explain in more detail. If you're talking about a single db field you can SELECT DISTINCT to not count duplicates. If you're talking about a single field in a single record you'll need to revisit your db design.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0
    basically i've got a table to record design jobs. within the table there is a field called department. What i need to be able to find out is how many design jobs have been allocated to each department. The problem being there are hundreds of departments and new ones are added all the time. I can get a count for specific departments but i'd like the count to be more dynamic than looking for a specified set of depts. Not sure if it can be done easily but like i said i'm very new to asp.

    hope this is a bit clearer.
  6. #4
  7. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    It depends on your table design. Typically you'd have at least two tables, one for jobs and one for departments. Then a simple SELECT statement can determine the number of jobs per department at any time.

    Visit sites like http://www.w3schools.com and take a look at some example asp code for data driven forms.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0
    thanks doug, what would the select statement be if i wanted to display the full list of departments with a total number of jobs?

IMN logo majestic logo threadwatch logo seochat tools logo