本文介绍了获取每列的百分比值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! **样本数据:** LINE_NO E_FIELD F_FIELD G_FIELD HSA_STATUS家庭CACHE_FAMILY计数百分比 23053B 00000 00000 00000 S峰会43 ?? 23053B 00000 00000 00000 T SUMMIT WER 144 ?? 23053B 00000 00000 00684 T SUMMIT WER 2 ?? 23053B 00353 00418 00684 T SUMMIT WER 1 ?? 23053B 00353 00418 00763 T SUMMIT WER 1 ?? 23053B 00353 00418 01512 T SUMMIT WER 1 ?? 23053B 00353 00418 06797 T SUMMIT WER 1 ?? 23053B 00353 00418 30228 T SUMMIT WER 1 ?? 23053B 00353 00418 31935 T SUMMIT WER 2 ?? 23053B 05601 01402 00758 T SUMMIT WER 1 ?? 23053B 05601 01402 09091 T SUMMIT WER 1 ?? 23053B 05601 01402 65053 T SUMMIT WER 1 ?? ---------------------------------------------- --------------------- 23054B 00000 00000 00000 S SUMMIT WER 37 ?? 23054B 00000 00000 00000 T SUMMIT WER 96 ?? 23054B 00353 00418 00758 T SUMMIT WER 1 ?? 23054B 00354 00414 01095 T SUMMIT WER 1 ?? 这是我的查询: SELECT LINE_NO, E_FIELD, F_FIELD, G_FIELD, HSA_STATUS, FAMILY, CACHE_FAMILY,计数=((SUM(TOTAL) ))) FROM ( SELECT LINE_NO, E_FIELD, F_FIELD,G_FIELD, HSA_STATUS, FAMILY, CACHE_FAMILY,计数(LINE_NO) as 总计 FROM TX_HSA_SUMM WHERE MT_TIMESTAMP2 BETWEEN (' 2013-03-07 10:10:00' ) AND (' 2013-03-08 10:20 :00') GROUP BY LINE_NO,E_FIELD,F_FIELD,G_FIELD,HSA_STATUS,FAMILY,CACHE_FAMILY ) as a GROUP BY LINE_NO,E_FIELD,F_FIELD,G_FIELD,HSA_STATUS ,FAMILY,CACHE_FAMILY,总计 ORDER BY LINE_NO,E_FIELD,F_FIELD,G_FIELD,HSA_STATUS, FAMILY,CACHE_FAMILY,总计 这实际上是我的样本数据。我已经计算了。正如您可以看到列标题。我的问题是我需要总结计数和每行所需的百分比。例如,上述记录的总数为** 199 **,因此第一个记录计数为** 43 **,因此计算结果应为** 43/199 * 100 **。如何查看百分比? ?? ??获得百分比的平均值。请帮助我,我迫切需要这个。只应该在破折号之后的那条特定的生产线上进行新的生产线,否则在计算百分比时,它应该只计算特定的生产线没有计数并获得百分比。 是否有任何建议可以显示如何获得计数。然后从那个总和计数到最后。计数应除以总和和* 100得到百分比。 25-3-2013今天所做的更改是: 我设法准备百分比。有没有想法如何根据不同的行号进行分区,并且计数值应该按顺序排列。谢谢 解决方案 **Sample data :**LINE_NO E_FIELD F_FIELD G_FIELD HSA_STATUS FAMILY CACHE_FAMILY Count Percentage 23053B 00000 00000 00000 S SUMMIT WER 43 ?? 23053B 00000 00000 00000 T SUMMIT WER 144 ?? 23053B 00000 00000 00684 T SUMMIT WER 2 ?? 23053B 00353 00418 00684 T SUMMIT WER 1 ?? 23053B 00353 00418 00763 T SUMMIT WER 1 ?? 23053B 00353 00418 01512 T SUMMIT WER 1 ?? 23053B 00353 00418 06797 T SUMMIT WER 1 ?? 23053B 00353 00418 30228 T SUMMIT WER 1 ?? 23053B 00353 00418 31935 T SUMMIT WER 2 ?? 23053B 05601 01402 00758 T SUMMIT WER 1 ?? 23053B 05601 01402 09091 T SUMMIT WER 1 ?? 23053B 05601 01402 65053 T SUMMIT WER 1 ?? ------------------------------------------------------------------- 23054B 00000 00000 00000 S SUMMIT WER 37 ?? 23054B 00000 00000 00000 T SUMMIT WER 96 ?? 23054B 00353 00418 00758 T SUMMIT WER 1 ?? 23054B 00354 00414 01095 T SUMMIT WER 1 ??This is my query:SELECT LINE_NO, E_FIELD, F_FIELD, G_FIELD, HSA_STATUS, FAMILY, CACHE_FAMILY, Count = ((SUM(TOTAL)) )FROM ( SELECT LINE_NO, E_FIELD, F_FIELD,G_FIELD, HSA_STATUS, FAMILY, CACHE_FAMILY, Count(LINE_NO) as Total FROM TX_HSA_SUMM WHERE MT_TIMESTAMP2 BETWEEN ('2013-03-07 10:10:00') AND ('2013-03-08 10:20:00') GROUP BY LINE_NO,E_FIELD,F_FIELD,G_FIELD,HSA_STATUS,FAMILY,CACHE_FAMILY ) as a GROUP BY LINE_NO,E_FIELD,F_FIELD,G_FIELD,HSA_STATUS,FAMILY,CACHE_FAMILY,total ORDER BY LINE_NO,E_FIELD,F_FIELD,G_FIELD,HSA_STATUS,FAMILY,CACHE_FAMILY,totalThis is my sample data actually. I already make the count. As You can see the column header. My problem is I need to sum the count and the for each row I need to get the percentage. For example the total for the above record is **199** so for the first record count is **43** so the calculation should be **43/199 * 100**. How can I view the percentage? The ?? mean column to get percentage. Please help me I need this urgently.it should be done only for that particular line line after the dash its a new line no so when calculating the percentage it should count only that particular line no count and get the percentage.Is there any suggestion to show how to get the count first. then from that sum the count and finally. the count should be divided with the sum and * 100 to get percentage.25-3-2013 changes made for today is:I manage to get the percentage ready. Is there any idea how to do partition according with the different line number and the count value should be in desc order. Thanks 解决方案 这篇关于获取每列的百分比值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-25 06:33