Q:

FIND THE MINIMUM VALUE

I wrote a code to find the minimum students age, but it doesn't work.
SELECT 
  S.stuName,
  (YEAR(GETDATE()) - YEAR(S.stuBirthdate)) AS AGE
FROM tblStudent S
WHERE (YEAR(GETDATE()) - YEAR(S.stuBirthdate)) <= ALL   
        (SELECT(YEAR(GETDATE()) - YEAR(S.stuBirthdate))
            FROM tblStudent )

Can You help with solving this issue, please?

A:

Wrong alias usage. Give a separate alias to the table in the subquery. Currently you  compare every student with him/herself.
SELECT 
  S.stuName,
  (YEAR(GETDATE()) - YEAR(S.stuBirthdate)) AS AGE
FROM tblStudent S
WHERE (YEAR(GETDATE()) - YEAR(S.stuBirthdate)) <= ALL   
        (SELECT(YEAR(GETDATE()) - YEAR(t2.stuBirthdate))
            FROM tblStudent t2 );

