我已经在QlikSense数据加载编辑器
中通过此SQL查询加载了一个表[RESOURCE_ALLOCATION]:
select t.rec_id as RESOURCE_ALLOC_TASKID,
t.name as RESOURCE_ALLOC_TASKNAME,
t.actual_starttime as RESOURCE_ALLOC_STARTTIME,
t.actual_endtime as RESOURCE_ALLOC_ENDTIME,
extract(year from t.actual_starttime) as RESOURCE_ALLOC_YEAR,
(t.actual_endtime - t.actual_starttime) as RESOURCE_ALLOC_DAYS,
t.resource_id as RESOURCE_ALLOC_ERSOURCEID,
r.name as RESOURCE_ALLOC_ERSOURCENAME
from public.dsh_project_tasks t, public.dsh_resources r
where t.resource_id = r.rec_id and extract(year from t.actual_starttime) = extract (year from t.actual_endtime);
然后我想通过在加载数据编辑器中的上一个查询之后的另一个查询中选择上一个加载的表[RESOURCE_ALLOCATION]来加载另一个表,如下所示
[Resource_Utilization]:
load rr.RESOURCE_ALLOC_ERSOURCENAME as busy_resourcename,
rr.RESOURCE_ALLOC_YEAR as busy_resourceyear,
Sum(rr.RESOURCE_ALLOC_DAYS) as busy_resourceDays,
if(Sum(rr.RESOURCE_ALLOC_DAYS) < 368, 'busy', 'free')as BUSY_RESOURCESTATUS
from RESOURCE_ALLOCATION rr
group by rr.RESOURCE_ALLOC_ERSOURCENAME, rr.RESOURCE_ALLOC_YEAR;
[Resource_Utilization]:
load rr.RESOURCE_ALLOC_ERSOURCENAME as busy_resourcename,
rr.RESOURCE_ALLOC_YEAR as busy_resourceyear,
(365 - Sum(rr.RESOURCE_ALLOC_DAYS)) as busy_resourceDays,
if((365 - Sum(rr.RESOURCE_ALLOC_DAYS)) < 366, 'free', 'busy') as BUSY_RESOURCESTATUS
from resource_allocation rr
group by rr.RESOURCE_ALLOC_ERSOURCENAME, rr.RESOURCE_ALLOC_YEAR;
但我在加载数据中有错误,说
发生以下错误: 路径无效 这里发生了错误:
[Resource_Utilization]:
load rr.RESOURCE_ALLOC_ERSOURCENAME as busy_resourcename,
rr.RESOURCE_ALLOC_YEAR as busy_resourceyear,
Sum(rr.RESOURCE_ALLOC_DAYS) as busy_resourceDays,
if(Sum(rr.RESOURCE_ALLOC_DAYS) < 368, 'busy', 'free')as BUSY_RESOURCESTATUS
from RESOURCE_ALLOCATION rr group by rr.RESOURCE_ALLOC_ERSOURCENAME, rr.RESOURCE_ALLOC_YEAR
请帮助,为什么我会收到此错误,尽管同样的Query在数据库控制台中选择数据很好?
答案 0 :(得分:2)
[Resource_Utilization]:
load rr.RESOURCE_ALLOC_ERSOURCENAME as busy_resourcename,
rr.RESOURCE_ALLOC_YEAR as busy_resourceyear,
Sum(rr.RESOURCE_ALLOC_DAYS) as busy_resourceDays,
if(Sum(rr.RESOURCE_ALLOC_DAYS) < 368, 'busy', 'free')as BUSY_RESOURCESTATUS
from RESOURCE_ALLOCATION rr
group by rr.RESOURCE_ALLOC_ERSOURCENAME, rr.RESOURCE_ALLOC_YEAR;
SQL语法仅在将查询传递给SQL Server时才有效。使用结果表时,您需要使用本机Qlik Sense脚本语言语法。它使您的脚本工作所需要的非常类似于此;
[Resource_Utilization]:
load RESOURCE_ALLOC_ERSOURCENAME as busy_resourcename,
RESOURCE_ALLOC_YEAR as busy_resourceyear,
Sum(RESOURCE_ALLOC_DAYS) as busy_resourceDays,
if(Sum(RESOURCE_ALLOC_DAYS) < 368, 'busy', 'free') as BUSY_RESOURCESTATUS
resident RESOURCE_ALLOCATION
group by RESOURCE_ALLOC_ERSOURCENAME, RESOURCE_ALLOC_YEAR;
关键更改是将FROM更改为RESIDENT,以便Sense知道查看它自己的结果表而不是您引用的表的某些外部源。 rr。 abbbreviations将导致失败,因为Sense每个脚本请求只能引用一个表。