Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In loading my data, I am using the Sum() function to create a new field. It works fine but I also want to filter on that field in my script (I only want to pull where Sum()>0). I've tried a variety of things with a WHERE statement with no luck. Suggestions?
You could put the Where on a Preceding Load, something like the below :
Temp :
LOAD * INLINE [
Dim, Fact
A, 0
A, 0
B, 1
B, 2
C, 3
C, 4
D, 5
D, 6
];
Data :
load
*
where SumFact > 0
;
load
Dim ,
Sum(Fact) as SumFact
resident Temp
Group By Dim
Order By Dim
;
Drop table Temp ;
You could put the Where on a Preceding Load, something like the below :
Temp :
LOAD * INLINE [
Dim, Fact
A, 0
A, 0
B, 1
B, 2
C, 3
C, 4
D, 5
D, 6
];
Data :
load
*
where SumFact > 0
;
load
Dim ,
Sum(Fact) as SumFact
resident Temp
Group By Dim
Order By Dim
;
Drop table Temp ;
Hi,
I confirm Bill answer. Using a where clause in a preceeding load is equivalent to the SQL "Having" clause.
Rgds,
Michael
Thank you very much to both of you! I was putting my WHERE statement in my SQL code not the Preceding Load.