I have the following query, which builds a new field successfully.
I need the (ABS(SplitRate) > '15.00000' in the Where clause to only be used when calculating the "NewField" results and not the entire query.
with cte as (
select pr.CompanyID, pr.JobType, pr.TempID, pr.CustomerNumber, pr.OfficeID, pr.SBUID, pr.JobNumber, pr.ConsultantID, pr.BatchID,
row_number() over(partition by pr.CompanyID, pr.JobType, pr.TempID, pr.CustomerNumber, pr.OfficeID, pr.SBUID, pr.JobNumber, pr.ConsultantID, pr.BatchID
order by pr.CompanyID, pr.JobType, pr.TempID, pr.CustomerNumber, pr.OfficeID, pr.SBUID, pr.JobNumber, pr.ConsultantID, pr.BatchID) rn
from [Temp_Rept] pr
WHERE (ABS(SplitRate) > '15.00000')
and pr.[CustomerNumber] = 113517
)
select CompanyID, JobType, TempID, CustomerNumber, OfficeID, SBUID, JobNumber, ConsultantID, BatchID,
case when rn=1 then 1 else 0 end NewField
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.