Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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:

tblScorecard:
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.

tblBluebook
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.





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





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