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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining 2 fields into 1 in query 1

Status
Not open for further replies.

eadiem

Technical User
Apr 8, 2004
47
CA
I am trying to create a query with one field called "Complaint Type". It will get data from two fields in a single table called "Complaints 2003", the fields are "Type1" and "Type2". The idea is to create a pie chart with all the complaint types summarized by type (noise, frequency, etc) without regard to whether it's type1 or type2.
My problem is getting the 2 fields to combine into 1 field...any ideas on how to do this through SQL?
Thanks.
Eadie
 
Hi eadiem,

What is in these fields, and how, exactly, do you want them 'combined'? For example, if you have one record with Type1=Noise and Type2=Frequency what do you want output?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Sorry for the confusion, I'll try to clarify.

The table has records:
ID Type1 Type2
1 Noise Frequency
2 Frequency (None)
3 Other (None)

I want the query to output:

Noise
Frequency
Frequency
Other

Then in my pie chart I will have a slice for each type, where the frequency slice is 50%, noise is 25%, other is 25%.

Hope that makes sense, let me know if I need to explain beter.

Thanks, Eadie
 
Try a union
[blue][tt]
(Select Type1 As [TheType] From tbl Where Type1 IS NOT NULL)

UNION ALL

(Select Type2 From tbl Where Type2 IS NOT NULL)
[/tt][/blue]
 
Thank you so much Golom! This was exactly what I needed and it worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top