안녕하세요, 나는 대부분의 항목이있는 값에 대한 레코드를 반환하려고합니다. 이 결과에서가장 높은 값의 레코드를 반환하는
+ -- + ----------------------- + ----------------- + ------ +
| | section | valuename | counts |
+ -- + ----------------------- + ----------------- + ------ +
| 1 | Customer & Markets | Completely Agree | 2 |
| 2 | Customer & Markets | Somewhat Agree | 4 |
| 3 | Data and Analytics | Completely Agree | 3 |
| 4 | Data and Analytics | Somewhat Disagree | 3 |
| 5 | Leadership & Culture | Completely Agree | 2 |
| 6 | Leadership & Culture | Somewhat Agree | 4 |
| 7 | Organization & Talent | Completely Agree | 3 |
| 8 | Organization & Talent | Somewhat Agree | 2 |
| 9 | Organization & Talent | Somewhat Disagree | 1 |
| 10 | Products & Services | Completely Agree | 3 |
| 11 | Products & Services | Somewhat Agree | 1 |
| 12 | Products & Services | Somewhat Disagree | 2 |
| 13 | Technology & Innovation | Completely Agree | 3 |
| 14 | Technology & Innovation | Somewhat Agree | 5 |
| 15 | Vision & Strategy | Completely Agree | 2 |
| 16 | Vision & Strategy | Somewhat Agree | 4 |
+ -- + ----------------------- + ----------------- + ------ +
, 내가 계산의 중간 값으로 부와 값 이름을 반환 할 :이 쿼리
SELECT b.section,c.valuename
,count(a.value) as counts
FROM [dbo].[SurveyResponse] a
JOIN [dbo].[Questions] b ON A.qid=b.qid
join [dbo].[SurveyValues] c on a.value=c.value
where profileid=2
group by b.section,c.valuename
order by 1,2
으로 나는이 결과 (Original Image)을 얻는다. 예를 들어, 7, 8, 9 행의 경우 3 번 값을 가진 행 7을 반환해야합니다.
누군가 도와 드릴 수 있습니까?
가장 큰 정수는 중간 값입니다. 샘플 데이터와 원하는 결과는 사용자가하려는 작업을 명확히합니다. –
아마도 모드 – maSTAShuFu
을 찾고 있거나 아마도 모드 결과에서 중간 값을 찾고있을 것입니다. 행 3 (모드)에 대한 카운트 3 4 7 10 13 .. 따라서 모드의 중간 값은 7입니다. – maSTAShuFu