我想计算每天命令要拍摄的员工数量。Ruby on rails积极记录多组记录来计算数字
Shoot.where("command_type = ?", "shoot").group("DATE(created_at)").group("employee_number").order("DATE(created_at)").count
它会给我喜欢
{[Wed, 03 Aug 2011, "7838744451"]=>2, [Wed, 03 Aug 2011, "8055898284"]=>11,[Fri, 05 Aug 2011, "9702553828"]=>1, [Fri, 05 Aug 2011, "9717466677"]=>1,[Fri, 05 Aug 2011, "8055898284"]=>1,[Wed, 06 Aug 2011, "8055898284"]=>5
我想有一个数组像一个输出: -
[2,0,3,1] // zero is for the dates when no record is there for that date. and number in the array is that number of the employees that has been ordered to shoot.
例如从数组:2的员工被勒令拍摄上周三,3日 0名员工被命令第4次拍摄,依此类推......
另外:我如何计算,所有员工被命令在一周/一个月内拍摄多少次。基本上有100名员工被命令第一周开枪。 120名员工为了第2周拍摄第1个月和第2个月等。
这听起来像一个有趣的项目... – sscirrus
谁低估了我?任何1可以告诉我最新的问题。这是一个糟糕的问题,或者这是提问的不好方法..请留下评论。 –
@sscrirrus项目的意义在哪里? –