PC Review


Reply
Thread Tools Rate Thread

Crosstab queries with more than one field

 
 
John S. Ford, MD
Guest
Posts: n/a
 
      20th Dec 2006
I understand the basic concept of crosstab queries and can create one in
Access 2000 (using the crosstab wizard). What I'm wondering is if it's
possible to create such a query using more than one fields. For example,
suppose I have table tblEmployeeReviews with fields ReviewIDNum, Name,
Efficiency (Good, Fair, Bad) and Speed (Good, Fair, Bad):

1 John Good Fair
2 John Bad Fair
3 Steven Fair Good
4 John Good Bad
5 Steven Bad Good

I want to create a crosstab query whose result looks like this:

Name EfficiencyTotal EfficiencyGood EfficiencyFair
EfficiencyBad SpeedTotal SpeedGood SpeedFair SpeedBad
John 3 1 0
2 3 0 2
1
Steven 2 0 1
1 2 2 0
0

The crosstab query wizard appears to only allow one to use one field at a
time (eg. Efficiency). Is there to use two or more?

John


 
Reply With Quote
 
 
 
 
John S. Ford, MD
Guest
Posts: n/a
 
      20th Dec 2006
By the way, my post didn't format the way I intended which was to have all
the fields of my crosstab query show up on one line with their counts lined
up below them.

John


 
Reply With Quote
 
=?Utf-8?B?RHVhbmUgSG9va29t?=
Guest
Posts: n/a
 
      20th Dec 2006
There is an FAQ that describes how to do this at
http://www.tek-tips.com/faqs.cfm?fid=4524. You may need to normalize your
table prior to creating the crosstab.
--
Duane Hookom
Microsoft Access MVP


"John S. Ford, MD" wrote:

> I understand the basic concept of crosstab queries and can create one in
> Access 2000 (using the crosstab wizard). What I'm wondering is if it's
> possible to create such a query using more than one fields. For example,
> suppose I have table tblEmployeeReviews with fields ReviewIDNum, Name,
> Efficiency (Good, Fair, Bad) and Speed (Good, Fair, Bad):
>
> 1 John Good Fair
> 2 John Bad Fair
> 3 Steven Fair Good
> 4 John Good Bad
> 5 Steven Bad Good
>
> I want to create a crosstab query whose result looks like this:
>
> Name EfficiencyTotal EfficiencyGood EfficiencyFair
> EfficiencyBad SpeedTotal SpeedGood SpeedFair SpeedBad
> John 3 1 0
> 2 3 0 2
> 1
> Steven 2 0 1
> 1 2 2 0
> 0
>
> The crosstab query wizard appears to only allow one to use one field at a
> time (eg. Efficiency). Is there to use two or more?
>
> John
>
>
>

 
Reply With Quote
 
John S. Ford, MD
Guest
Posts: n/a
 
      20th Dec 2006
Duane,

Is that technique the same as creating multiple crosstab queries (one for
each field) and then inner joining them on the grouping field?

John

"Duane Hookom" <duanehookom@NO_SPAMhotmail.com> wrote in message
news:E8F56B5F-20AE-413E-A1AB-(E-Mail Removed)...
> There is an FAQ that describes how to do this at
> http://www.tek-tips.com/faqs.cfm?fid=4524. You may need to normalize your
> table prior to creating the crosstab.
> --
> Duane Hookom
> Microsoft Access MVP
>
>
> "John S. Ford, MD" wrote:
>
> > I understand the basic concept of crosstab queries and can create one in
> > Access 2000 (using the crosstab wizard). What I'm wondering is if it's
> > possible to create such a query using more than one fields. For

example,
> > suppose I have table tblEmployeeReviews with fields ReviewIDNum, Name,
> > Efficiency (Good, Fair, Bad) and Speed (Good, Fair, Bad):
> >
> > 1 John Good Fair
> > 2 John Bad Fair
> > 3 Steven Fair Good
> > 4 John Good Bad
> > 5 Steven Bad Good
> >
> > I want to create a crosstab query whose result looks like this:
> >
> > Name EfficiencyTotal EfficiencyGood EfficiencyFair
> > EfficiencyBad SpeedTotal SpeedGood SpeedFair SpeedBad
> > John 3 1 0
> > 2 3 0 2
> > 1
> > Steven 2 0 1
> > 1 2 2 0
> > 0
> >
> > The crosstab query wizard appears to only allow one to use one field at

a
> > time (eg. Efficiency). Is there to use two or more?
> >
> > John
> >
> >
> >



 
Reply With Quote
 
Gary Walter
Guest
Posts: n/a
 
      20th Dec 2006
PMFBI

possibly another way of looking at it using a
normalizing query ("qryUnion") on "yurtable"
(change to real name of your table) where I
just couldn't use reserved Access word "Name"
as a field name....

SELECT
t.AName,
"Efficiency" AS ReviewProp,
t.Efficiency AS Rating
FROM yurtable t
UNION ALL SELECT
t.AName,
"Speed",
t.Speed
FROM yurtable AS t;

result from your example data:

AName ReviewProp Rating
John Efficiency Good
John Efficiency Bad
Steven Efficiency Fair
John Efficiency Good
Steven Efficiency Bad
John Speed Fair
John Speed Fair
Steven Speed Good
John Speed Bad
Steven Speed Good


TRANSFORM Nz(Count([ReviewProp] & [Rating]),0) AS cnt
SELECT
q.AName,
Sum(cnt) As TotalRatingsCnt,
Abs(Sum([ReviewProp]="Efficiency")) AS EfficiencyTotal,
Abs(Sum([ReviewProp]="Speed")) AS SpeedTotal
FROM qryUnion AS q
GROUP BY q.AName
PIVOT [ReviewProp] & [Rating]
IN
("EfficiencyGood",
"EfficiencyFair",
"EfficiencyBad",
"SpeedGood",
"SpeedFair",
"SpeedBad");

Apologies again for butting in...

"John S. Ford, MD" wrote:
>I understand the basic concept of crosstab queries and can create one in
> Access 2000 (using the crosstab wizard). What I'm wondering is if it's
> possible to create such a query using more than one fields. For example,
> suppose I have table tblEmployeeReviews with fields ReviewIDNum, Name,
> Efficiency (Good, Fair, Bad) and Speed (Good, Fair, Bad):
>
> 1 John Good Fair
> 2 John Bad Fair
> 3 Steven Fair Good
> 4 John Good Bad
> 5 Steven Bad Good
>
> I want to create a crosstab query whose result looks like this:
>
> Name EfficiencyTotal EfficiencyGood EfficiencyFair
> EfficiencyBad SpeedTotal SpeedGood SpeedFair SpeedBad
> John 3 1 0
> 2 3 0 2
> 1
> Steven 2 0 1
> 1 2 2 0
> 0
>
> The crosstab query wizard appears to only allow one to use one field at a
> time (eg. Efficiency). Is there to use two or more?
>
> John
>
>



 
Reply With Quote
 
Gary Walter
Guest
Posts: n/a
 
      20th Dec 2006
maybe "more accurate" row headings:

TRANSFORM Nz(Count([ReviewProp] & [Rating]),0) AS cnt
SELECT
q.AName,
Sum(cnt) AS TotalBothRatings,
Count(cnt) AS NumDistinctRatings,
Abs(Sum([ReviewProp]="Efficiency")) AS EfficiencyTotal,
Abs(Sum([ReviewProp]="Speed")) AS SpeedTotal
FROM qryUnion AS q
GROUP BY
q.AName
PIVOT [ReviewProp] & [Rating]
In
("EfficiencyGood",
"EfficiencyFair",
"EfficiencyBad",
"SpeedGood",
"SpeedFair",
"SpeedBad");


 
Reply With Quote
 
David F Cox
Guest
Posts: n/a
 
      20th Dec 2006
Oner way to go about this is to concatenate the fields to make a single
field using format staements or other methods to ensure proper column
alignment.


"John S. Ford, MD" <(E-Mail Removed)> wrote in message
news:ubdiAt$(E-Mail Removed)...
>I understand the basic concept of crosstab queries and can create one in
> Access 2000 (using the crosstab wizard). What I'm wondering is if it's
> possible to create such a query using more than one fields. For example,
> suppose I have table tblEmployeeReviews with fields ReviewIDNum, Name,
> Efficiency (Good, Fair, Bad) and Speed (Good, Fair, Bad):
>
> 1 John Good Fair
> 2 John Bad Fair
> 3 Steven Fair Good
> 4 John Good Bad
> 5 Steven Bad Good
>
> I want to create a crosstab query whose result looks like this:
>
> Name EfficiencyTotal EfficiencyGood EfficiencyFair
> EfficiencyBad SpeedTotal SpeedGood SpeedFair SpeedBad
> John 3 1 0
> 2 3 0 2
> 1
> Steven 2 0 1
> 1 2 2 0
> 0
>
> The crosstab query wizard appears to only allow one to use one field at a
> time (eg. Efficiency). Is there to use two or more?
>
> John
>
>
>



 
Reply With Quote
 
John S. Ford, MD
Guest
Posts: n/a
 
      21st Dec 2006
Thanks for all the suggestions. That's all VERY helpful. I've got a lot of
things to try now!

John


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Crosstab Reports from Crosstab Queries vincelts@singnet.com.sg Microsoft Access Reports 4 25th Feb 2007 01:04 AM
Crosstab queries with more than one field John S. Ford, MD Microsoft Access Queries 7 21st Dec 2006 01:05 AM
Can parameter queries working with crosstab queries. =?Utf-8?B?RmF0TWFu?= Microsoft Access Queries 2 5th Nov 2004 07:10 PM
Multiple Crosstab Queries grouped by a field none@none.com Microsoft Access Queries 0 23rd Mar 2004 08:49 PM
Field Size in crosstab queries MIke McKelvey Microsoft Access Queries 1 24th Sep 2003 02:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:07 PM.