Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 14th, 2006, 02:09 PM
Authorized User
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with multiple total query.

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
Total Query kbsudhir Access 1 February 16th, 2008 05:41 AM
Problem in calculating total sales in MDX query jaee SQL Server 2000 0 March 9th, 2007 11:10 AM
run total in query stoneman Access 1 December 23rd, 2003 04:43 AM
Having problems returning total rows to asp Trojan_uk SQL Server 2000 1 December 9th, 2003 12:59 PM
total columns in sql query nlicata SQL Server ASP 1 August 4th, 2003 06:33 PM





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