Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Based on the month condition, I need to populate the value from one row to another. If the CP data has lower terr counts, we must incorporate the ORG terr counts (CP < ORG) in the script.
Kindly help me out.
Expected Output:
CP_Team_Flag | Sales_District | TerrCount |
CP | IN1001 | 1 |
ORG | IN1001 | 1 |
CP | IN1028 | 2 |
ORG | IN1028 | 2 |
CP | IN5002 | 4 |
ORG | IN5002 | 1 |
Thanks in advance.
Hi, if 'CP' and 'ORG' are the only values on that field you can do:
Table:
LOAD
CP_Team_Flag,
Sales_District,
If(Peek(Sales_District)=Sales_District
,If(Peek(TerrCount)>TerrCount
,Peek(TerrCount)
,TerrCount)
,TerrCount) as TerrCount
Resident tmpTable
Order By Sales_District, CP_Team_Flag desc;
DROP table tmpTable;