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!

How to extract records that aren't distinguised in a field

Status
Not open for further replies.

starbest

Technical User
Aug 21, 2007
4
US
I have inherited a database that was not set up as being relationally friendly. I am trying to report on traffic conditions in comparison with weather conditions. There are four categories of weather distinguished by their own separate fields. The name of the fields are: Sunny, Rainey, Foggy, Stormy. There is one field (conditions), however, that indicates traffic conditions: light, moderate, heavy.

The query looks like this:

CONDITIONS SUNNY RAINEY FOGGY STORMY
Light 0 0 1 0
Light 0 0 0 1
Heavy 1 0 0 0
Moderate 0 1 0 1

The 1(s) indicate "yes" and the 0(s)indicate "no".
I have been asked to report on all conditions that are other than SUNNY, RAINEY, FOGGY, STORMY. How can I extract that data to place it in a abstract category called "Other"? The report would look like the following.

CONDITIONS SUNNY RAINEY FOGGY STORMY Other
Light 0 0 1 0
Light 0 0 0 1
Heavy 1 0 0 0
Moderate 0 1 0 1


 




Hmmmmmmm........

What's the business case for this assignment?

What is the Criteia for "Other"

This table seems so general. For instance a relevant piece of data might be a date of observation, and another might be a location.

Wht kind of entity is this report being prepared for?





Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 
Thanks Skip . . .

. . . for your reply and inquiries. These four weather condition categories would really have been easier to work with had only one field been created called: "Weather Conditions", with a combo box added to the user entry form with selections for: Sunny, Rainey, Foggy, Stormy.

I have, since this posting, created a field in order to replicate a one field "Weather Conditions" by creating a field in the report's underlying query called Weather Conditions and I have developed it using he following conditional if statement.

IIf([Sunny]<>0,yes,2)+ IIF([Rainey]<>0,yes,3))

I am attemping to assign values to this field that would represent each kind of weather condition. The only problem now is to figure out the syntax to string these IIf statements along without causing them to add numbers together.

In other words:
How do string along these multiple conditions without using the "+" sign? This method is causing the numbers to add themselves together rather than remain static or the same as assigned.
 




String concatenation operator is &

Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 




String concatenation operator is &

I'd also use UNION queries to stack the data into a Normalized structure.
Code:
Select Condition, 'Sunny' as [WeatherCond], Sunny
From Table
UNION ALL
Select Condition, 'Rainey', Rainey
From Table
UNION ALL
....


Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top