How do I run a query only asking for a max date of attendance? I'm new to SQL and the school I work for wants to run a query on students' transcripts. We want to find out the most recent school the student attended prior to coming to ours. I think I need to use a Max date clause, but I'm not sure. Can someone help me? Thank you in advance.
I have to assume some things here because I'm not sure what your table looks like or what your columns are, but let's assume you have a table called StudentHistory. 

Let's say StudentHistory contains the columns StudentID, StudentName, SchoolName, LeaveDate.

Each student may have multiple entries depending on how many schools they have frequented. These entries can be ordered by the LeaveDate column to get a chronological history of attended schools.

What you want as an output can be articulated as: 


  For each student, return the StudentID, StudentName, SchoolName for
  the last School attended based on the latest LeaveDate.


You can achieve this using the RANK function:

WITH StudentData AS (
    SELECT StudentID, 
        StudentName, 
        SchoolName, 
        RANK() OVER(PARTITION BY StudentID ORDER BY LeaveDate DESC) AS TheRank
)
SELECT * 
FROM StudentData 
WHERE TheRank = 1 ;