Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cross tab with missing values

Status
Not open for further replies.

Ronze55

MIS
Jul 9, 2004
54
0
0
US
Hi All,

I am trying to make my query result look like this:

category first second final
Elephant 5 2 7
tigers
bears 3 3

as you can see i have a row "tigers" without any values.

my raw information would look like this

category order value
elephant first 5
elephant second 2
bears first 3

the query i am using looks like this

select category
, count(iif(order = 'first', value, null))
, count(iif(order = 'second', value, null)
, count(value)
from table1
group by category

how can i get the tiger row in my final view?

thanks in advanced for any help you can send my way.
Christina

 
do you have a table that contains elephant, bears and tigers as values in a field (like a lookup table)?

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
I can make one

it would look like this

Key Category
1 elephants
2 tigers
3 bears

thanks
Christina
 
Have a look at LEFT JOIN

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top