STATE CITY ZIP CAR_BRAND SALES_NUMBER
---------- ---------- ---------- ---------- ------------
CA SACRAMENTO 95834 NISSAN 500
NY NY 10038 LEXUS 100
NY NY 10038 BMW 200
NY NY 10038 VOLVO 250
PA MILLMONT 17845 BMW 50
PA MILLMONT 17845 VOLVO 50
PA MILLMONT 17845 HONDA 150
TX SAN MARCOS 78666 VOLVO 50
TX SAN MARCOS 78666 BMW 100
STATE CITY ZIP CAR_BRAND SALES_NUMBER RANK
---------- ---------- ---------- ---------- ------------ ------
CA SACRAMENTO 95834 NISSAN 500 1
NY NY 10038 LEXUS 100 1
NY NY 10038 BMW 200 2
NY NY 10038 VOLVO 250 3
PA MILLMONT 17845 BMW 50 1
PA MILLMONT 17845 VOLVO 50 1
PA MILLMONT 17845 HONDA 150 2
TX SAN MARCOS 78666 VOLVO 50 1
TX SAN MARCOS 78666 BMW 100 2
You need to give some more information about how you give RANKS ? Like based on what conditions ? The output you shown is confusing. We cannot guess the requirement.....
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
1. Sort your input based on STATE, CITY, ZIP.
2. Use a stage variable to remember the concatenated string State:City:Zip of the previous row and compare it with the current row's concatenated value. You will use the RowProcCompareWithPreviousValue function available in the SDK to achieve this.
3. Use a derivation such that if current string is new, then RANK = 1, else RANK = RANK + 1.
It looks like a goup change detection and giving a running number. Its been covered a lot. Search the forum for various ways. One has been described by gateleys.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
If you check the 5th and 6th row, as the SALES_NUMBERS are same they should get the same rank "1" and the successive rank after the 2 consecutive rank 1's should get 2 not 3.
(Rank Vs Dense Rank)
Use a stage variable to remember the concatenated string State:City:Zip of the previous row and compare it with the current row's concatenated value. You will use the RowProcCompareWithPreviousValue function available in the SDK to achieve this.
In that case also concate SALES_NUMBER and compare with the previous row.
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
Well you will have to do a column by column check then. Compare column 1, if they are same, check scond column, if same check third, if same, check the 5th column.
Now if the 5th column is same, refresh the rank to 1, if its different, increment the rank.
If any of the first three columns are different, start from 1 again.
Makes sense ???
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
STATE CITY ZIP CAR_BRAND SALES_NUMBER RANK
---------- ---------- ---------- ---------- ------------ -------
CA SACRAMENTO 95834 NISSAN 500 1
NY NY 10038 VOLVO 250 1
NY NY 10038 BMW 200 2
NY NY 10038 LEXUS 100 3
PA MILLMONT 17845 HONDA 150 1
PA MILLMONT 17845 BMW 50 2
PA MILLMONT 17845 VOLVO 50 2
TX SAN MARCOS 78666 BMW 100 1
TX SAN MARCOS 78666 VOLVO 50 2