To be honest its really not clear what you're trying to do.
I think you need to look into subqueries
This is an example of what you might want
Code:
SELECT row_number() OVER (ORDER BY KWDPWLITI, CITY_1) AS Row_No , E1_Emp051_3.FULLNAME, E1_Emp001_3.CITY_1, E1_Emp001_3.KWDPWLITI, E1_Emp001_3.TEL_1, E1_Emp001_3.TEL_2, E1_Emp001_3.COMPANY, E1_Emp001_3.YPOL, E1_Emp001_3.SINTZIROU,
DATEDIFF(DAY,DATEPAR,GETDATE()) AS MESOS, E1_Emp016_3.KWDPar, E1_Emp016_3.TimePar FROM E1_Emp001_3, E1_Emp051_3,E1_Emp016_3 WHERE E1_Emp051_3 .KWD = E1_Emp001_3.KWDPWLITI AND E1_EMP016_3.kWDPEL=E1_Emp001_3.KWD AND E1_Emp001_3.YPOL<>0 AND E1_Emp016_3.KWDPAR=1 OR E1_Emp016_3.KWDPAR=3
WHERE E1_Emp016_3.Id =
(SELECT TOP 1 ID
FROM E1_Emp016_3 AS E1_Emp016_3_SUB
WHERE E1_Emp016_3.CustomerId = E1_Emp016_3_SUB.CustomerId
ORDER BY DatePar DESC
)
It's a bit clumsy and doesn't really match your style and might not match your schema, but for each customerId it only displays the maximum datepar.
Let us know if that's any help.