Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
I am working on Sql servar 2005; here is the query
SELECT distinct DailyAttendence.Empid,DailyAttendence.LeaveType,DailyAttendence.today as 'Half day taken at', EmployeeOnFulldayleave.LeaveDay FROM DailyAttendence
CROSS JOIN EmployeeMaster CROSS JOIN EmployeeOnFulldayleave
where DailyAttendence.LeaveType='h' and EmployeeOnFulldayleave.fleave =1 and DailyAttendence.Empid=2


it is still showing two records! it should only be one record!

2 H 06-08-2013 06-08-2013
SQL


2 H 06-08-2013 06-09-2013

plz help me its urgent!
Thankx in advance
Priya Tiwari
Posted

1 solution

They are distinct and different - so it is doing exactly what it should. Your query returns two records which match your criteria - so either you need to refine your criteria, or limit the number of record you return with TOP:
SQL
SELECT DISTINCT TOP 1 ...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900