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 |
Kimi86
Yak Posting Veteran
79 Posts |
Posted - 2012-05-22 : 04:58:45
|
Hi All,This is really urgent and important as well, but I cant seem to get a simple thing right. Please helpMy Data looks like thisPartKey QuestionKey1001 11001 41001 31001 11001 11002 41002 31002 21002 41002 41002 31003 21003 51003 11003 81003 21003 6 Expected Result Set:Need Frequesnct of each question for each PartkeyPartKey QuestionKey Frequency1001 1 31001 4 11001 3 11002 4 31002 3 21002 2 11003 2 21003 5 11003 1 11003 8 11003 6 1Scripts are below:Create table Part(PartKey int,QuestionKey int)Insert into Part values (1001,1)Insert into Part values (1001,4)Insert into Part values (1001,3)Insert into Part values (1001,1)Insert into Part values (1001,1)Insert into Part values (1002,4)Insert into Part values (1002,3)Insert into Part values (1002,2)Insert into Part values (1002,4)Insert into Part values (1002,4)Insert into Part values (1002,3)Insert into Part values (1003,2)Insert into Part values (1003,5)Insert into Part values (1003,1)Insert into Part values (1003,8)Insert into Part values (1003,2)Insert into Part values (1003,6)Do I need cursors?? |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-05-22 : 05:19:32
|
select PartKey, QuestionKey,count(QuestionKey) as frequency from Partgroup by PartKey, QuestionKeyMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|