Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 13th, 2006, 12:09 PM
Authorized User
Join Date: Apr 2006
Location: Edmonton, , Canada.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with query for multiple totals

Hi guys,

I need a hand with a query of an access database.

Basically, I just need the SQL code behind this query.

I've got a table that has quite a bit of fields in it, but the ones that are of concern are:

ScorecardID (Primary Key)
EmployeeID (occurs multiple times, each employee has a bunch of 'scorecards' in this table)
Score (a % value - their grade)
ScorecardType (value from 1-13 which identifies what type of scorecard this is)

There is also another table which holds information about all the employees. This table will have EVERY employee in it.. the tblScorecard table will just show employees that have scorecards.

EmployeeID (matches up to employee ID in the tblScorecard table)
StaffName (name of the employee)

Basically here is what I need:

I need to write a query which lists off each EmployeeID (preferably everyone that exists in tblBluebook, although I would be OK with just having the people that have scorecards), their Average Score (i.e. Avg(Score) ) of all their Scorecards, a Count of all the scorecards where ScorecardType = 1, a Count of all the scorecards where ScorecardType = 2, etc.... up to a Count of all the scorecards where ScorecardType = 13.

I'm trying to wrap my head around how to do this with just one query. The only way I've thought of so far is to have one query that lists every employee, then open up another query that checks the avg score and total of scorecardtype = 1, then another query for 2, etc... up to 13. However, as you can guess, this will mean that there will be THOUSANDS of queries to the database, as opposed to possibly just 1.

Anyone know how I can do this in just 1 query? A union perhaps? I'm not sure what the union would look like in this case.... any help would be appreciated here.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple field query PLUS Durwood Edwards Access 5 July 26th, 2005 09:08 AM
Multiple table Query-HELP Kathryn SQL Language 1 March 22nd, 2005 10:57 AM
Totals vs Crosstab Query tlwaltz BOOK: Expert One-on-One Access Application Development 0 October 13th, 2004 06:45 PM
Multiple Joins in Multiple Table Search query pookster Access 4 September 23rd, 2004 03:04 PM
Multiple Database query nlicata SQL Language 1 August 15th, 2003 03:34 AM

All times are GMT -4. The time now is 04:08 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.