Using SQL Server 2000
How to avoid the duplicate values?
Query
SELECT DISTINCT
Modification.dbo.Reference.Dates AS DailyDate,
tmp_Cardevent2.PERSONID,
tmp_Cardevent2.empname,
tmp_cardevent2.cardno,
tmp_Cardevent2.titlecode,
tmp_Cardevent2.titlename,
tmp_Cardevent2.departname,
CASE
WHEN tmp_Cardevent2.CardEventDate = Modification.dbo.Reference.Dates
THEN tmp_Cardevent2.CardEventDate
ELSE '-----'
END AS EMPDATE,
CASE
WHEN tmp_Cardevent2.CardEventDate = Modification.dbo.Reference.Dates
THEN tmp_Cardevent2.Intime
ELSE '-----'
END AS INTIME
WHEN tmp_Cardevent2.CardEventDate = Modification.dbo.Reference.Dates
THEN tmp_Cardevent2.outtime
ELSE '-----'
END AS outtime
FROM tmp_Cardevent2
CROSS JOIN Modification.dbo.Reference
ORDER BY
PERSONID, DAILYDATE DESC
Output:
DailyDates, Personid, empname, cardno, titlecode, titlename, departname, empdate, intime, outtime
12/30/2008 A201 A Cherian 3201 018 Chief Air Traffic Service Assistant Air Traffic Services ----- -----
12/30/2008 A201 A Cherian 3201 018 Chief Air Traffic Service Assistant Air Traffic Services 20081230 07:51:31 15:54:38
12/30/2008 A201 A Cherian 3201 018 Chief Air Traffic Service Assistant Air Traffic Services 20081230 07:51:31 15:54:38
What problem in my query, why am getting duplicate values? How to avoid the duplicate values.
Please can any help to solve my problem.