title: SQL FOREACH LOOP Syntax
body: <p>Ok from what I can tell in my searches most of the people answering a question related to this is against <code>foreach</code> loops in sql.
  But I actually need to do a <code>foreach</code> loop. my problem is that i can't for the life of me remember the syntax for doing it and like I said nobody seems to want to give up the layout of it, so now I am here asking for any help at all.</p>
  
  <p>Maybe its not necessary for a foreach loop, but its the best possible way i can see.</p>
  
  <p>I need to do a <code>SELECT COUNT(*)</code> statement on a table that contains 20120 signals for about 800 units in a 1 month time period. So i cant be certain about any specific amount of signals from each unit. Now that's why I need to do the count. I need to get accurate amount of signals for each unit, and doing it one unit number at a time is not an option. So I need to work through each unitID and get a count of the amount of signals passed by that unit in a certain time period. </p>
  
  <p>So basically I need a way to run through all the unitID's and get a count for each individual unitID without giving a unitID to look for.</p>
  
  <p>Any help would be greatly appreciated. 
  If you can not think of another way than a <code>foreach</code> loop too do this and you have the syntax for the <code>foreach</code> loop. Please just post it?? This is rather urgent</p>