Why am I getting the An expression of non-boolean type specified in a context where a condition is expected, near ',' error
SQL SERVER doesn't support this.
You have to switch to a subwquery


CREATE TABLE mytable (Permit integer,Stampdate Datetime)
GO




INSERT INTO mytable (Permit,Stampdate) VALUES (1,GETDATE()),
 (1,DATEADD(day, DATEDIFF(day, 0, GETDATE()), '05:30:00'))
GO




SELECT * 
FROM mytable As t1
WHERE 
  EXISTS ( SELECT 1 FROM
  
   ( SELECT Permit,MAX(Stampdate) AS Stampdate  
    FROM mytable As t2
       GROUP BY Permit) t2 WHERE  t1.Permit = t2.Permit 
      AND t1.Stampdate = t2.Stampdate
)
GO


Permit | Stampdate              
-----: | :----------------------
     1 | 2020-07-02 16:22:06.897




SELECT * 
FROM mytable As table1
GO


Permit | Stampdate              
-----: | :----------------------
     1 | 2020-07-02 16:22:06.897
     1 | 2020-07-02 05:30:00.000




    SELECT Permit,MAX(Stampdate) AS Stampdate  
    FROM mytable As t2
GROUP BY Permit
GO


Permit | Stampdate              
-----: | :----------------------
     1 | 2020-07-02 16:22:06.897


db&lt;&gt;fiddle here