BleepingComputer.com: Database Help

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Database Help Count fields with a criteria

#1 User is offline   mr phil 

  • New Member
  • Pip
  • Find Topics
  • Group: Members
  • Posts: 13
  • Joined: 01-March 07
  • Location:South Yorkshire

Posted 14 June 2007 - 05:43 AM

Hi there,

i'm new to databased so i apologise if this is really easy.

i have a database where i have a department in 1 field, member of staff in another and a grade in the 3rd (ranging from 1-4). How do i get a query to add the amount of 1's then 2's etc per department?

Thanks for any help
Phil

#2 User is offline   Nikas 

  • Distinguished Member
  • PipPipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 650
  • Joined: 03-July 05
  • Gender:Male
  • Location:Singapore

Posted 14 June 2007 - 11:54 AM

SELECT COUNT(grade)
FROM Department
WHERE Department = HR (for e.g.) AND grade = 1

I don't really get what you mean, so this query actually count the number of grade = 1 in HR department.

If I got you wrong, let me know and I can change accordingly.

#3 User is offline   ErrorMessage 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 19
  • Joined: 23-August 06
  • Location:Devon

Posted 12 September 2007 - 11:04 AM

could try

select department,grade, count(member of staff)
from tablename
group by department,grade

will give you result set like this (for example)

department grade count
hr 1 1
hr 2 2
hr 3 44

You'll need to get the column and table names right.

Good luck.
Knowledge is knowing a tomato is a fruit; Wisdom is not putting it in a fruit salad

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users