I have a loop problem.
I want to collect name counts for each items for every months
This code skips variables with empty value, but I needs those values.
below is a bit of the tables involve
Name
id int
date date
item_id int
so I need to loop them and put it in an array.
@names = Name.find(:all)
@list=Array.new
@names.each do |e|
@list << Name.count(:all,:conditions=>["item_id = ? and DATE FORMAT(date,%M) = ?",e.item_id,date],:group =>DATE FORMAT(date,%m),:order=>"date ASC")
end
so, for every item_id which have empty count, it did not go into the array.
how do I include them?
1 Answer