Hi
I know i must be missing something obvious, but i have been trying to get the following to work. Below is my ideal, but i understand it doesn't work like this. If i add dLastVisited to my select distinct statement, no longer will i only return distinct lSamplePointIDs. All I need is the distinct lSamplePointIDs which meet the @SiteID criteria, ordered by dLastVisited (earliest first - no date being the highest priority) Can anyone let me know where i am going wrong?
Thanks
John
I know i must be missing something obvious, but i have been trying to get the following to work. Below is my ideal, but i understand it doesn't work like this. If i add dLastVisited to my select distinct statement, no longer will i only return distinct lSamplePointIDs. All I need is the distinct lSamplePointIDs which meet the @SiteID criteria, ordered by dLastVisited (earliest first - no date being the highest priority) Can anyone let me know where i am going wrong?
SQL:
SELECT Distinct tblPumpPointDownload.lSamplePointID
FROM tblPumpPointDownload
inner join
tblSamplePointDownload ON tblPumpPointDownload.lSamplePointID = tblSamplePointDownload.lSamplePointID
WHERE(tblSamplePointDownload.lSiteID = @lSiteID)
GROUP BY tblPumpPointDownload.dLastVisited ,lSamplePointID,lpumppointid
order by tblPumpPointDownload.dLastVisited
Thanks
John