Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi this is Ramesh.

How to use the Distinct Key word in Bellow Query without changing pivot.
SQL
SELECT EmpName, [Visited], [ptp]
FROM
(SELECT EmpName, Code
FROM @ClientVisit) As Souce
PIVOT (COUNT(Code) FOR Code IN ([Visited], [ptp])) As p
Posted

1 solution

Try

SQL
SELECT EmpName, [Visited], [ptp]
FROM
(SELECT DISTINCT EmpName, Code
FROM @ClientVisit) As Souce
PIVOT (COUNT(Code) FOR Code IN ([Visited], [ptp])) As p.
 
Share this answer
 
Comments
ARK Kambhampati 3-Apr-12 3:04am    
Hi Stalin it's working fine. But Actual I need don't mention the [visited],[ptp].
because client add new status in future. My problem is distinct Status.

Any way Thank You for Reply....

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