Complex query and update

Complex query and update

I need to count by grouping fields FIELD1 and FIELD2.  I need to group by FIELD1 and FIELD2, and get the count of each group. For example VALUE1, VALUE2  =  30 OCCURRENCES.  Value3, value4 = 40 occurrances.

I only need the value groups where the count is >1.  Then I will get the FIELD1 value of the group and update all rows containing this value. 

I know how to write this easily in SQL but how do I implement it in Zoho  ? Once this function is written  I will make it run nightly.