Rows in their own columns depending on their date and symbolized by 'x'
Posted
by Chandradyani
on Stack Overflow
See other posts from Stack Overflow
or by Chandradyani
Published on 2010-03-19T04:26:19Z
Indexed on
2010/03/19
4:41 UTC
Read the original article
Hit count: 367
sql-server
|datetime
Dear All, please help me since I'm newbie in SQL Server. I have a select query that currently produces the following results:
DoctorName Team Visit date
dr. As A 5
dr. Sc A 4
dr. Gh B 6
dr. Nd C 31
dr As A 7
Using the following query:
SELECT d.DoctorName, t.TeamName, ca.VisitDate FROM cActivity AS ca
INNER JOIN doctor AS d ON ca.DoctorId = d.Id
INNER JOIN team AS t ON ca.TeamId = t.Id
WHERE ca.VisitDate BETWEEN '1/1/2010' AND '1/31/2010'
I want to produce the following:
DoctorName Team 1 2 3 4 5 6 7 ... 31 Visited
dr. As A x x ... 2 times
dr. Sc A x ... 1 times
dr. Gh B x ... 1 times
dr. Nd C ... X 1 times
© Stack Overflow or respective owner