473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

query problem

I really need help me with this. I'm sure it's really easy for most. I
really appreciate any help. Thanks!

I have tables Employee and Sales. In Employees the yes/no field
IsManager denotes Manager. Sales has Year, Region, EmplyeeID, Sales
and other results of the sale.

I want to compare sales for several years between 4 salesmen. One of
them is also the Manager. The trouble is that all have worked during
different time periods from each other in this Dept. except for the
Manager, who has been here all years and worked with everyone. Plus
the sales are in different regions. A query results in this data set
that has the correct information but some not pertinent data as well.

Now the data look like this but how can I get the reduced data set(s)
I've shown farther down below? I think I need to specify criteria
within some fileds that set certain conditions to be matched in other
fields.
Year Region Salesman Sales Position
1997 2 Cabstone 6259 Manager
1998 7 Cabstone 1018 Manager
1999 11 Cabstone 2749 Manager
1999 11 Jumper 2927 Salesman
2000 16 Cabstone 4459 Manager
2000 16 Jumper 4984 Salesman
2000 17 Cabstone 5717 Manager
2001 32 Cabstone 4423 Manager
2002 42 Cabstone 3495 Manager
2002 43 Cabstone 2583 Manager
2003 58 Cabstone 4547 Manager
2003 58 Dunsten 5026 Salesman
2003 59 Cabstone 3432 Manager
2004 62 Cabstone 5487 Manager
2004 62 Dunsten 5067 Salesman
2004 62 Sevenrude 4743 Salesman
2004 63 Cabstone 3236 Manager
2005 71 Cabstone 3285 Manager
2005 71 Dunsten 3516 Salesman
2005 71 Sevenrude 3753 Salesman
2006 79 Cabstone 3003 Manager
2006 79 Dunsten 2807 Salesman
2006 79 Jumper 2542 Salesman
2006 79 Sevenrude 3749 Salesman
2006 80 Cabstone 2668 Manager
2006 80 Sevenrude 3124 Salesman

I think I'd like to end up with these 3 comparisons:
Jumper vs Cabstone
1999 11 Cabstone 2749 Manager
1999 11 Jumper 2927 Salesman
2000 16 Cabstone 4460 Manager
2000 16 Jumper 4985 Salesman
2006 79 Cabstone 3003 Manager
2006 79 Jumper 2543 Salesman

Dunsten vs Cabstone
2003 58 Cabstone 4547 Manager
2003 58 Dunsten 5027 Salesman
2004 62 Cabstone 5487 Manager
2004 62 Dunsten 5068 Salesman
2005 71 Cabstone 3286 Manager
2005 71 Dunsten 3517 Salesman
2006 79 Cabstone 3003 Manager
2006 79 Dunsten 2808 Salesman

Sevenrude vs Cabstone
2004 62 Cabstone 5487 Manager
2004 62 Sevenrude 4744 Salesman
2005 71 Cabstone 3286 Manager
2005 71 Sevenrude 3754 Salesman
2006 79 Cabstone 3003 Manager
2006 79 Sevenrude 3749 Salesman
2006 80 Cabstone 2668 Manager
2006 80 Sevenrude 3125 Salesman

Mar 14 '07 #1
3 2506
I think if you specify the names of the salesmen you want to compare
in the criteria of your query, you should be able to get the results
you want - i.e., "Sevenrude" or "Cabstone" in the criteria field of
the salesman field should give you the last set of results. If you
wanted to get fancy, you could use parameters, [person one] or [person
two] - that way you wouldn't have to change the query every time you
wanted a different comparison. Or if Cabstone is going to be
consistent across your results, you could do a combination of the two.

HTH.

Mar 14 '07 #2
On Mar 14, 5:09 pm, "hbean" <bean...@gmail.comwrote:
I think if you specify the names of the salesmen you want to compare
in the criteria of your query, you should be able to get the results
you want - i.e., "Sevenrude" or "Cabstone" in the criteria field of
the salesman field should give you the last set of results. If you
wanted to get fancy, you could use parameters, [person one] or [person
two] - that way you wouldn't have to change the query every time you
wanted a different comparison. Or if Cabstone is going to be
consistent across your results, you could do a combination of the two.

HTH.

hbean,
Yes. I se that Thanks. But I don't think I was clear that I want to
get the average (totals query) for the salesman & for the Manager for
their respective sales in the same years & same regions worked. Right
now the Manager average is across all of his years.

Thanks for your help.

santoni

Mar 16 '07 #3
On Mar 15, 5:00 pm, "santoni" <santon...@gmail.comwrote:
On Mar 14, 5:09 pm, "hbean" <bean...@gmail.comwrote:
I think if you specify the names of the salesmen you want to compare
in the criteria of your query, you should be able to get the results
you want - i.e., "Sevenrude" or "Cabstone" in the criteria field of
the salesman field should give you the last set of results. If you
wanted to get fancy, you could use parameters, [person one] or [person
two] - that way you wouldn't have to change the query every time you
wanted a different comparison. Or if Cabstone is going to be
consistent across your results, you could do a combination of the two.
HTH.

hbean,
Yes. I se that Thanks. But I don't think I was clear that I want to
get the average (totals query) for the salesman & for the Manager for
their respective sales in the same years & same regions worked. Right
now the Manager average is across all of his years.

Thanks for your help.

santoni
Okay, here's what worked for me:

Set up your query as a totals query. Include your four fields. For
the "Salesman" field, under the "Total", change it to "Where" - and
then in the criteria, you can either list the two people you want to
compare or use parameters. Don't display this field. For the "Sales"
field, change the "Total" to "Avg". - This actually yields more than
what you want, because it also gives you the years just with Capstone
alone, but you can set your criteria for the specific years if you
need to.

HTH.

Apr 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Wescotte | last post by:
Here is a small sample program I wrote in PHP (running off Apache 1.3.31 w/ PHP 5.0.1) to help illustrates problem I'm having. The data base is using DB2 V5R3M0. The client is WinXP machine using...
3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
1
by: Jeff Blee | last post by:
I hope someone can help me get this graph outputing in proper order. After help from Tom, I got a graph to display output from the previous 12 months and include the average of that output all in...
8
by: Adam Louis | last post by:
I would like help resolving this problem. I'm a novice who's been hired to query a hospital database and extract useful information, available to me only in a dynamically generated, downloadable...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
11
by: Andy_Khosravi | last post by:
My problem: I'm having trouble with a query taking much too long to run; a query without any criteria evaluating only 650 records takes over 300 seconds to run (over the network. On local drive...
4
by: Konrad Hammerer | last post by:
Hi! I have the following problem: I have a query (a) using another query (b) to get the amount of records of this other query (b), means: select count(MNR) as Number from...
4
by: Stan | last post by:
I am using MS Office Access 2003 (11.5614). My basic question is can I run a query of a query datasheet. I want to use more that one criteria and can not get that query to work. I thought I...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.