dimanche 18 janvier 2015

How to get unique records in the SQL Server 2000

I have 4 tables



Employeetab
Employeeid EmployeeName
1 xyz
2 abc
3 mno
4 pqr
PurchaseRequesttab
PRID Employeeid PRNR
1 1 pr1

Statustab
StatusID Statusmsg
1 approve by manager
2 approve by CC manager
3 approve by designer
4 approve by BU head
ApprovalStatustab
PRID StatusID Employeeid ApprovalDate
1 1 3 jan 1 2015
1 2 3 jan 3 2015
1 4 4 Jan 5 2015


Result should be



PRNR EmployeeName Statusmsg
1 mno approve by CC manager


Below is my query, which gives duplicate



Select distinct P.PRNR, EmployeeName, Statusmsg from Employeetab as E
inner join PurchaseRequesttab AS P ON E. Employeeid = p. Employeeid
inner join ApprovalStatustab as A ON P. PRID = A. PRID
inner join Statustab as S on A. StatusID = S. StatusID


How to get unique records in the result set


Aucun commentaire:

Enregistrer un commentaire