我正在使用Alasql合并json对象。
我有这个alasql查询:
SELECT Employment.*,
EmploymentCore.CompanyCode AS EmploymentCore_CompanyCode,
Accumulator_DaysInAdvance.VacationYearValue AS Accumulator_DaysInAdvance_Value,
Accumulator_AgreementYearlyDays.VacationYearValue AS Accumulator_AgreementYearlyDays_Value,
Person.UserId AS Person_UserId,
FROM ? AS EmploymentCore
RIGHT JOIN ? AS Employment
ON Employment.Id = EmploymentCore.Id
LEFT JOIN ? AS Accumulator_DaysInAdvance
ON Accumulator_DaysInAdvance.WorkNumber = Employment.WorkNumber
AND Accumulator_DaysInAdvance.AccumulatorId = 'b82'
AND Accumulator_DaysInAdvance.AccumulatorType = 'd'
LEFT JOIN ? AS Accumulator_AgreementYearlyDays
ON Accumulator_AgreementYearlyDays.WorkNumber = Employment.WorkNumber
AND Accumulator_AgreementYearlyDays.AccumulatorId = 'b59'
AND Accumulator_AgreementYearlyDays.AccumulatorType = 'n'
JOIN ? AS Person
ON Person.Id = EmploymentCore.PersonId
我有这些对象:
尽管查询中的累加器是多余的。 因此,与其传递两次累加器对象, 有办法代替数字吗?
赞:
SELECT Employment.*,
EmploymentCore.CompanyCode AS EmploymentCore_CompanyCode,
Accumulator_DaysInAdvance.VacationYearValue AS Accumulator_DaysInAdvance_Value,
Accumulator_AgreementYearlyDays.VacationYearValue AS Accumulator_AgreementYearlyDays_Value,
Person.UserId AS Person_UserId,
FROM $1 AS EmploymentCore
RIGHT JOIN $2 AS Employment
ON Employment.Id = EmploymentCore.Id
LEFT JOIN $3 AS Accumulator_DaysInAdvance
ON Accumulator_DaysInAdvance.WorkNumber = Employment.WorkNumber
AND Accumulator_DaysInAdvance.AccumulatorId = 'b82'
AND Accumulator_DaysInAdvance.AccumulatorType = 'd'
LEFT JOIN $3 AS Accumulator_AgreementYearlyDays
ON Accumulator_AgreementYearlyDays.WorkNumber = Employment.WorkNumber
AND Accumulator_AgreementYearlyDays.AccumulatorId = 'b59'
AND Accumulator_AgreementYearlyDays.AccumulatorType = 'n'
JOIN $4 AS Person
ON Person.Id = EmploymentCore.PersonId