Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have two tables: company and customer.
___________________________________________________________________________________
company:
LOAD DATE,
MACHINE,
plan_hrs,
[Mec. Hr.]
FROM
customer:
LOAD DATE,
MACHINE,
plan_hrs_cust,
[Mec. Hr._cust]
FROM
___________________________________________________________________________________
I need to calculate in script the expression bellow:
if(sum(plan_hrs_cust)>0,
sum(plan_hrs_cust),
sum(plan_hrs))
If the hrs of the customer is greater than 0, then consider the customer's hours, else consider company's hrs.
I have in chart, but I want to do it in the script.
Follow the files.
Tks
I note that you have a synthetic key here, it would be best to join these tables together and use the formula to create a new field.
Here is the script:
company:
LOAD DATE,
MACHINE,
plan_hrs,
[Mec. Hr.]
FROM ...
//customer:
Left Join(company)
LOAD DATE,
MACHINE,
plan_hrs_cust,
[Mec. Hr._cust]
FROM ...
New:
Load *,
If(plan_hrs_cust>0, plan_hrs_cust, plan_hrs) as plan_hrs_real
Resident company;
Drop table company;
I note that you have a synthetic key here, it would be best to join these tables together and use the formula to create a new field.
Here is the script:
company:
LOAD DATE,
MACHINE,
plan_hrs,
[Mec. Hr.]
FROM ...
//customer:
Left Join(company)
LOAD DATE,
MACHINE,
plan_hrs_cust,
[Mec. Hr._cust]
FROM ...
New:
Load *,
If(plan_hrs_cust>0, plan_hrs_cust, plan_hrs) as plan_hrs_real
Resident company;
Drop table company;
Hi Samuel,
kindly concatenate two tables and create new field
company:
LOAD DATE,
MACHINE,
plan_hrs,
[Mec. Hr.]
FROM
Concatenate
customer:
LOAD DATE,
MACHINE,
plan_hrs_cust,
[Mec. Hr._cust]
FROM
New:
LOAD
DATE,
MACHINE,
sum(plan_hrs)as plan_hrs,
sum(plan_hrs_cust)as plan_hrs_cust,
IF(SUM(plan_hrs_cust)>0,SUM(plan_hrs_cust),SUM(plan_hrs))as plan_hrs_real
Resident company Group by MACHINE,DATE;
drop table company;
Thanks
Company:
LOAD
DATE,
MACHINE,
plan_hrs,
[Mec. Hr.]
FROM
Concatenate
Customer:
LOAD
DATE,
MACHINE,
plan_hrs_cust,
[Mec. Hr._cust]
FROM
NoConcatenate
Cust_Company:
LOAD
DATE,
MACHINE,
Sum(plan_hrs)as plan_hrs,
Sum(plan_hrs_cust)as plan_hrs_cust,
If(Sum(plan_hrs_cust) > 0, Sum(plan_hrs_cust), Sum(plan_hrs)) as plan_hrs_real
Resident Company
Group by DATE, MACHINE;
Drop Table Company;