I am currently working on an sql query to find employees which handled more orders than average in a certain half year. For arguments sake the half year is august-dec1997. I will use two queries, one to calculate COUNT and one for the avg:
So far I have the COUNT query sorted:
SELECT Employees.EmployeeID, Count(Orders.EmployeeID) AS CountOfOrders
FROM Employees, Orders
WHERE (((Employees.EmployeeID)=[Orders].[EmployeeID]))
GROUP BY Employees.EmployeeID;
However, I am uncertain how to proceed from here and find the >AVG part of this query. I know it would be something like this:
SELECT qrycountOfOrders.EmployeeID, Employees.FirstName, Employees.LastName, qrycountOfOrders.CountOfOrders,
FROM qrycountOfOrders, Employees
WHERE qrycountOfOrders.EmployeeID = Employees.EmployeeID;
Any help would be appreciated- thankyou!
4 1298
Is this SQL query in Access?
I am currently working on an sql query to find employees which handled more orders than average in a certain half year. For arguments sake the half year is august-dec1997. I will use two queries, one to calculate COUNT and one for the avg:
So far I have the COUNT query sorted:
SELECT Employees.EmployeeID, Count(Orders.EmployeeID) AS CountOfOrders
FROM Employees, Orders
WHERE (((Employees.EmployeeID)=[Orders].[EmployeeID]))
GROUP BY Employees.EmployeeID;
However, I am uncertain how to proceed from here and find the >AVG part of this query. I know it would be something like this:
SELECT qrycountOfOrders.EmployeeID, Employees.FirstName, Employees.LastName, qrycountOfOrders.CountOfOrders,
FROM qrycountOfOrders, Employees
WHERE qrycountOfOrders.EmployeeID = Employees.EmployeeID;
Any help would be appreciated- thankyou!
Sorry yes it is in Access I completely forgot to say that!
This will give you the average:
SELECT Avg(qrycountOfOrders.CountOfOrders) AS AvgOfCountOfOrders
FROM qrycountOfOrders;
The easiest thing to do would be to establish this result as a control on a form. For this example lets call the form AverageOrders and the control AverageCount.
SELECT qrycountOfOrders.EmployeeID, Employees.FirstName, Employees.LastName, qrycountOfOrders.CountOfOrders,
FROM qrycountOfOrders, Employees
WHERE qrycountOfOrders.EmployeeID = Employees.EmployeeID
AND qrycountOfOrders.CountOfOrders > [Forms]![AverageOrders]![AverageCount];
I am currently working on an sql query to find employees which handled more orders than average in a certain half year. For arguments sake the half year is august-dec1997. I will use two queries, one to calculate COUNT and one for the avg:
So far I have the COUNT query sorted:
SELECT Employees.EmployeeID, Count(Orders.EmployeeID) AS CountOfOrders
FROM Employees, Orders
WHERE (((Employees.EmployeeID)=[Orders].[EmployeeID]))
GROUP BY Employees.EmployeeID;
However, I am uncertain how to proceed from here and find the >AVG part of this query. I know it would be something like this:
SELECT qrycountOfOrders.EmployeeID, Employees.FirstName, Employees.LastName, qrycountOfOrders.CountOfOrders,
FROM qrycountOfOrders, Employees
WHERE qrycountOfOrders.EmployeeID = Employees.EmployeeID;
Any help would be appreciated- thankyou!
Thanks a lot I will try it as a form =)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Zapp |
last post by:
Hi
Can anyone tell me why my form script fails at this line
<form action="$_SERVER" method="POST">
when running on my ISP which is using PHP version 4.3.2,
Configure Command './configure'...
|
by: john bailo |
last post by:
I just installed mono from ximian on my redHat 9 workstation
and wrote a simple program from the interesting book
ado.net in c# by Mahesh Chand.
mono is fun
( is there ado for linux ? ...
|
by: Jim Hubbard |
last post by:
Yet another hotfix alert (http://www.kbalertz.com/Feedback_823535.aspx) that
states "To resolve this problem immediately, contact Microsoft Product
Support Services to obtain the hotfix."
...
|
by: zeny |
last post by:
Hey you all, i´ve been confrontated with a bizarre thing: i´m doing a binary tree in C and in the file Tree.h i did this:
//headers & other stuff
typedef struct Node Node_t;
struct Node{
...
|
by: stromhau |
last post by:
When compiling i get these warnings and i dont know why. Can anyone please explain ?
Tommy,
1>------ Build started: Project: sdl, Configuration: Release Win32 ------
1>Compiling......
|
by: aling |
last post by:
Damn! SQLServer2000 can't add a NOT NULL COLUMN even in one empty
existing table!
That is, A is the existing table and it is emtpy, I want to add one NOT
NULL COLUMN (col_new) to A using following...
|
by: Vaurdan |
last post by:
Hello,
I've this code:
def print_tabela(tabela):
print "Tabela 1 | Tabela 2"
for linha in tabela:
tmp = linha.split(":")
print tmp + " | " + tmp,
But give me this error:
Tabela 1 | Tabela 2
|
by: Ian11 |
last post by:
I am new to Linux and Xammp and have downloaded everthing and the server is running. I hve set up a firewall and given permisions to "permit= "80 21"" and I can access the server via localhost on the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |