November 4, 2013 at 1:09 pm
I have a table containing 50000 records. The fields are, Phase, KVA, Amt and Group. To begin with, Group = 0 for all records. I have an input variable #Grps, telling me how many final groups the user wants. I am to determine the groups by Phase, KVA, and AMT in that order. For instance, All records with Phase = 1, KVA = 25 and AMT <= xxx would go into Group = 1, All records with Phase = 1, KVA = 25, Amt > xxx and Amt <= yyy would go into Group = 2, etc. until the maximum amt has been assigned to a group for this Phase and KVA. Then we would go to Phase 1, KVA = 50, and do it all over again. I know there's a formula for this, but I've been out of school a long time, and don't remember enough to find it on the internet. Can anyone reading this tell me what the formula is, or give me an efficient query to accomplish my goal?
The amount ranges are determined by the number of records (#Recs) in that grouping (Phase = 1, KVA = 25) divided by the total number of records(#TotRecs) times the #Grps, which gives us the number of groups allotted to this grouping (#SubGrps), so the number of records in each group within that grouping would be #Recs/#SubGrps or xxx in my example above. yyy would then be twice that amount.
This will require some tweaking, but if I can get this far, I can handle the rest.
Thanks guys
#
November 4, 2013 at 1:17 pm
some scripts to define table along with example data and expected output from example data will help considerably please.
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply