Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I have this script:
tmp:
Crosstable(category, value, 2)
LOAD startDate,
endDate,
categoryA
categoryB
categoryC
FROM ...
Outputs:
LOAD startDate,
endDate,
category,
sum(value) as Total
FROM ...
Group by category
The first script (tmp) works and create the table.
The second script (Outputs) trowh an exception, invalid expression.
I don't understand why?
Please help me.
Thanks.
Hi Andrea, the group clause should have all field outside an agregation function:
Outputs:
LOAD startDate,
endDate,
category,
sum(value) as Total
FROM ...
Group by startDate, endDate, category;
Or something like:
Outputs:
LOAD Min(startDate) as startDate,
Max(endDate) as endDate,
category,
sum(value) as Total
FROM ...
Group by category
Hi Andrea, the group clause should have all field outside an agregation function:
Outputs:
LOAD startDate,
endDate,
category,
sum(value) as Total
FROM ...
Group by startDate, endDate, category;
Or something like:
Outputs:
LOAD Min(startDate) as startDate,
Max(endDate) as endDate,
category,
sum(value) as Total
FROM ...
Group by category
I've used the first solution and it works very good.
Thanks
Hi Andrea,
Try like this:
tmp:
Crosstable(category, value, 2)
LOAD startDate,
endDate,
categoryA
categoryB
categoryC
FROM ...
Outputs:
LOAD startDate,
endDate,
category,
sum(value) as Total
FROM ...
Group by category,startDate,endDate;
Your all the fields with in with table apart from the aggregated filed should be in group by.
Br,
KC