--Sample Data
CREATE TABLE PivotTable ( ID int, DayNme char(3), DayNo int)
INSERT PivotTable
SELECT 1 , 'SUN', 1 union all
SELECT 2 , 'MON', 2union all
SELECT 3 , 'TUE', 3union all
SELECT 4 , 'WED', 4union all
SELECT 5 , 'THU', 5union all
SELECT 6, 'FRI', 6union all
SELECT 7 , 'SAT', 7
-- Pivot Query
SELECT ID, CASE WHEN [SUN] >= 1 THEN 'True' ELSE 'False' END AS [SUN]
, CASE WHEN [MON] >= 1 THEN 'True' ELSE 'False' END AS [MON]
, CASE WHEN [TUE] >= 1 THEN 'True' ELSE 'False' END AS [TUE]
, CASE WHEN [WED] >= 1 THEN 'True' ELSE 'False' END AS [WED]
, CASE WHEN [THU] >= 1 THEN 'True' ELSE 'False' END AS [THU]
, CASE WHEN [FRI] >= 1 THEN 'True' ELSE 'False' END AS [FRI]
, CASE WHEN [SAT] >= 1 THEN 'True' ELSE 'False' END AS [SAT]
FROM PivotTable P
PIVOT ( COUNT(DayNo) FOR DayNme IN ([SUN], [MON], [TUE], [WED], [THU], [FRI],[SAT]))P
Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator