I am trying a SQL query MSSQL server 2005.
select distinct emp_code , SSN, name
from dbo.employee
where
(City = 'Abc')
or
(Country = 'India')
and Joining_date between getdate()-60 and getdate()
which is returning 76 queries
But if instead I use
select distinct emp_code
from dbo.employee
where
(City = 'Abc')
or
(Country = 'India')
and Joining_date between getdate()-60 and getdate()
which is returning 73 records.
I understand that in first query Server is returning where all 3 columns are distinct. How should I write the query if I want only distinct emp_code ?
I have tried using group by emp_code but it is throwing an error Please help!
Aucun commentaire:
Enregistrer un commentaire