Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have query
SQL
select [1] AnalysisCount,[2] DietitianCount,[3] DoctorCount ,AppointmentDate
from
(
select AppointmentDate ,AppointmentDate as dd, AppointmentTypeID from  dbo.Appointment
)  ss
pivot (count(dd)  For AppointmentTypeID in ([1],[2],[3]) )
as pvt

ineed out put as

Date AnalysisCount,DietitianCount,DoctorCount

ie count is seperated by coma as single column
PLZ help
Posted

Example Query: You May Try this method:
SQL
create table piv (number int primary key,marks decimal(18,2))
insert into piv(number,marks) values (1,24),(2,154),(4,345),(6,234.56),(8,456.90)
select * from piv

select number,AVG(marks) as Average from piv group by number

--pivot
select 'marks'as number,[1]avv,[2]qq,[4]qq,[6]qq,[8]q from (select * from piv)as sourcetable
pivot(avg(marks) for number in ([1],[2],[3],[4],[5],[6],[7],[8]))as pivottable
 
Share this answer
 

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