douxi3432 2018-11-20 14:58
浏览 43

需要帮助根据优先级选择对轮询选项进行排名

Need some help in ranking poll options, tried doing by multidimensional arrays but nothing worked.

My data structure is as per below:

**Table** Poll

**Id** **Question** **op1**  p1  **op2** p2 **op3** p3  **op4** p4 **op5** p5

1            q1 ?          Excellent 5  Better   4  Good  3  Ok   2   Not OK 1

2            q2 ?          Sure      5   Perfect 4  Fine  3  Never 2    No  1

**Table** Answer

**id**  **poll_id**  **users_id**  **answer**  **resultOrder**
---------------------------------------------------------------


  1          1           1            Excellent     1

  2          1           1            Better        2

  3          1           1            Ok            3

  4          1           1            Good          4

  5         1           1             Not Ok         5

  6          1           2            Excellent     1

  7          1           2            Ok            2

  8          1           2            Better        3

  9          1           2            Not Ok        4

  10         1           2            Good          5 

Each user will submit five options priorities them as per his suggestion

Option will get ranking as per counts

e.g Excellent selected for 2 times for first preference it will get 100 points and others will get 80,60,40,20 points based on their counts for all priorities.

if count ties matches points will be given on p1, p2 column in table poll

**For Example if my group by [answer] look like below 5 people voted Excellent as first preference, 4 people voted better as second preference and so on till Not Ok preferred by 1 person for fifth preference **

Answer     count(answer)   it should set point like this

Excellent     5                  100

Better        4                   80

Good          3                  60  

Ok            2                  40

Not Ok        1                  20

Hope this is possible. I tried it many ways, but no luck.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示