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

need help with query 1

Status
Not open for further replies.

JennW

IS-IT--Management
Jan 30, 2001
39
0
0
US
I am trying to create a query that will consolidate fields of information into one alias field.

For example:

The alias field should be comprised of information that appears first in this order of fields.

If there is data in DPS1, use that data..otherwise
use the data in DPS2....otherwise
use the data in DPS3....otherwise
use the data in DPS4....otherwise
use the data in DPS5.

My intent is for all of these records to come together and there be just one field that represents whichever DPS had the latest data.

Can this be done in a simple select query or is there some other way I should be looking?

Thank you,

JennW
 
you could do this

query1
select dps1 as dps from table where not isnull(dps1);

query2
select dps2 as dps from table where isnull(dps1) and not isnull(dps2);

query3
select dps3 as dps from table where isnull(dps1) and isnull(dps2) and not isnull(dps3);

Union query
select dps from query1
union
select dps from query2
union
select dps from query3;

You get the idea
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top