Skip to content

Instantly share code, notes, and snippets.

@jonwitts
Created June 25, 2020 11:47
Show Gist options
  • Save jonwitts/ade50f0975a9384860b52a983aebbca6 to your computer and use it in GitHub Desktop.
Save jonwitts/ade50f0975a9384860b52a983aebbca6 to your computer and use it in GitHub Desktop.
SQL Query to extract the newest student photo file from the iSAMS database
-- SQL Script to get the latest student photos out of iSAMS
SELECT txtEmailAddress,
(SELECT TOP (1) txtPath FROM TblPupilManagementPictures
WHERE (txtSchoolID = TblPupilManagementPupils.txtSchoolID)
ORDER BY intOrder DESC) AS txtPupilPicturePath
FROM TblPupilManagementPupils
WHERE (intSystemStatus = '1') AND
((SELECT TOP (1) txtPath
FROM TblPupilManagementPictures AS TblPupilManagementPictures_1
WHERE (txtSchoolID = TblPupilManagementPupils.txtSchoolID)
ORDER BY intOrder DESC)
IS NOT NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment