Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Reference a table before field name with SQL

Hi Everyone,

I have two tables, with the same fields in both (I know what you are thinking, but I inherited this from someone else...!). I need to link them as they contain useable data in both tables. For instance SPO2Meas is the field name but I can't work out how to reference this to the first table PE29_AOCResults and not to PE29_AOCScores.

In other words, how can I make it work like table1.fieldname as newfieldname

hope this helps, here is the script.

AOC:

LOAD

//SQL SELECT

1

PRFUniqueId as %KEY_PRFUID,

SPO2Meas;

SQL

SELECT *

//WHERE IncDate >= DateAdd(month,-48,GETDATE())

) prf

ON

aor.PRFUniqueId = prf.PRFUniqueId

inner JOIN

[TCMPRF].[dbo].[PE29_AOCSCores] aos

ON

aos.PRFUniqueId = aor.PRFUniqueId



FROM TCMPRF.dbo."PE29_AOCResults" aor

INNER JOIN

(SELECT PRFUniqueId FROM TCMPRF.dbo."PE29_AOCResults"

where IncDate between '01-Nov-2008' and getdate()



as Counter,





2 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

Hi Phil,

You may use:

Qualify *;

or

Unqualify *;

Instead of * you could also specify fields you want to qualify or unqualify. See documentation for these two functions.

Not applicable
Author

Thats not quite what I am after.

In the table AOCResults there is a field with data, named SPO2Meas.

The same field exists in AOCScores.

I need the SQL to only display the data from AOCResults.

Does this help?