SQL statements in database reference

Discussion created by ByronCoughlin on Oct 30, 2014
Latest reply on Nov 3, 2014 by ByronCoughlin

I have two tables on a sql server. I would like to get the last name of an individual in the personnel table. The id of the person is located in another table  as "operatorId". I have both tables linked as tables in the Pi system Explorer. The record that holds the operatorId is the last record in the table based on creation date field. Looking to do something like this.


SELECT tblPersonnel.perLastName

FROM tblPersonnel Join tblPolantDisplay ON tblPersonnel.perId = tblPlantDisplay.plaOperationAuthorityId

WHERE (SELECT TOP 1 FROM tblPlantDisplay ORDER BY plaCreateDate DESC)


Is there a way to get the last name as an attribute in an Operator Authority element