I'm getting a application going and I'm fairly new to sqlite. I'm writing the following query but I'm getting the error "Error while executing SQL query on database 'SampleDataBase': ambiguous column name: nClientWorkerID". Below is the script I'm writing.
select distinct tblWorkers.nClientWorkerID, nWorkerFirstname, nWorkerLastname, nWorkerSuffix, nTitle, nStatusShort, nStatusColor from tblWorkers
left join tblTitles on tbltitles.iTitleID = tblworkers.iTitleID
left join tblWorkers on tblEDLWorkers.nClientWorkerID = tblWorkers.nClientWorkerID
left join tblEDLWorkers on tblEventDateLocations.iEDLID = tblEDLWorkers.iEDLID
left join tblEventDateLocations on tblEventDates.iEventDateID = tblEventDateLocations.iEventDateID
left join
(select nClientWorkerID, nStatusColor, nStatusShort from tblTimeLog
join tblTimeLog on tblTimeStatuses.iTimeStatusID = tblTimeLog.iNewStatusID
where tblTimeLog.iTimeLogID in
(select max(iTimeLogID)
from tblTimelog group by nClientWorkerID)
group by nClientWorkerID, nStatusColor, nStatusShort) TimeLog
on TimeLog.nClientWorkerID = tblworkers.nClientWorkerID
where tblEventDates.dEventDate = (select date('now'))
and
((EDL.nClientLocationID = (select nvalue from tblElectionSettings where nKey = 'CurrentLocation')
and
tblEventDates.iEventID = (select cast(nvalue as integer) from tblElectionSettings where nKey = 'CurrentEvent'))
or
tblWorkers.nClientWorkerID in (select nClientWorkerID from tblTimeLog where dCreationDate = (select datetime('now'))
and nClientLocationID = (select nvalue from tblElectionSettings where nKey = 'CurrentLocation'))
)
The area I'm concerned with is :
left join (select nClientWorkerID, nStatusColor, nStatusShort from tblTimeLog
This is originally a query written in sql server and I'm converting to sqlite. Not sure how to handle this.
Aucun commentaire:
Enregistrer un commentaire