Count no. of Array Elements of the same value

einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
Hi guys,

is it possible in an easy way to count the no. of Array Elements of the same value? I know I can use some kind of loop, but I'm asking for an easier and fast way just to be sure.

E.g.
Int[1] = 45;
Int[2] = 36;
Int[3] = 128;
Int[4] = 56;
Int[5] = 45;
...
Int[16] = 45;
...
Int[22] = 45;

COUNT WHERE Int = 45 should be 4.
"Money is likewise the greatest chance and the greatest scourge of mankind."

Comments

  • GRIZZLYGRIZZLY Member Posts: 127
    If you could use temporary table instead of array, then you could easily set filter and get number by COUNT command.
    Sincerely yours, GRIZZLY
    Follow my blog at http://x-dynamics.blogspot.com
  • matttraxmatttrax Member Posts: 2,309
    A loop is the best way to go here. You can either use the execution time on the insert into the array to have it sorted or use the execution time on the traversal through the unsorted array to count the elements. Depends on which one you need to be faster.
Sign In or Register to comment.