Table Structure :
CREATE TABLE dbo.DwlEntry
(
Id INT IDENTITY(1,1),
UserName VARCHAR(100),
ConfigItem VARCHAR(100),
Component VARCHAR(100),
TimeLogged DECIMAL(13,2)
)
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','AFOTA','Documentation','3')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','GENERAL','Troubleshooting','3')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','AFOTA','CodeChange','3')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','GENERAL','ProjectTraining','1')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','GENERAL','Troubleshooting','5')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','AFOTA','CodeChange','1')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','AFOTA','CodeChange','5')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bubai','GENERAL','ProjectTraining','4')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','AFOTA','Documentation','2')
INSERT INTO dbo.DwlEntry(UserName,ConfigItem,Component,TimeLogged) VALUES('Bhanu','GENERAL','ProjectTraining','4')
I want the Result in below way . Config item would be first row. and grouping come Horizontally like below Format
| But I want it in this in this below Format : | |||||
| ConfigItem | AFOTA | AFOTA | GENERAL | GENERAL | |
| UserName | Documentation | CodeChange | ProjectTraining | Troubleshooting | Total |
| Bhanu | 2 | 4 | 4 | 5 | 15 |
| Bubai | 3 | 5 | 5 | 3 | 16 |
| Total | 5 | 9 | 9 | 8 | 31 |
Replies
Know the answer? Post it — somebody with the same question will find it here.