Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2011-01-13 : 01:29:04
|
I am using sql server 2005, SSrs 2005I am preparing a voting form where employee can nominate (from nomination table) a employee and fill the option (Good , avg , excelence) against the List of parameter I have parameter tables (para_master)Like Parano Attributes1 Comminication2 Displine3 Team Work And Option master asOpid Option1 good2 Avg3 Excellence Now I use to store record in two table One Hdr and other DetailsHdrYear Nominatedby Nominee HdrID 2011 abc imran 1 2011 efg imran 2 2011 123 Marshal 3 And Details tables stores details of employee rated against the parameterHdrID paraid optioned1 1 31 2 21 3 32 1 32 2 32 3 13 1 33 2 33 3 3 Now I want ouput as Imran (2 Nomination)Parameter Good Avg excellence1 0 0 22 0 1 13 1 0 1 Marshal(1 Nomination)Parameter Good Avg excellence1 0 0 12 0 0 13 0 0 1 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-13 : 13:05:57
|
[code]SELECT p.Parano,SUM(CASE WHEN o.Option = 'Good' THEN 1 ELSE 0 END) AS Good,SUM(CASE WHEN o.Option = 'Avg' THEN 1 ELSE 0 END) AS Avg,SUM(CASE WHEN o.Option = 'Excellence' THEN 1 ELSE 0 END) AS ExcellenceFROM Hdr hINNER JOIN Details dON d.optioned = h.HdrIDINNER JOIN Option oON o.Opid = d.optionedINNER JOIN para_master pON p.Parano = d.paraid WHERE h.Nominee = 'Imran'GROUP BY p.Parano [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|