Subject | RE: [firebird-support] Need Speed Optimization for SQL |
---|---|
Author | Svein Erling Tysvær |
Post date | 2015-04-16T07:29:48Z |
>Hi SET,Yes, sorry I forgot group by:
>
>Nice to see you here, but I am getting below error after executing your sql, i think group by clause is needed, would you please help?
with TMP(PK_JOB_ITEMS) as
(select distinct PK_JOB_ITEMS
from CRM_JOB_ITEMS where FK_JOB = '{8BDDED49-8509-48C1-A169-B7E68A74C230}')
select
Sum(cdi.QUANTITY) AS Delivered,
cdi.FK_JOB_ITEM
from tmp t
join CRM_DOCUMENT_ITEMS cdi on t.PK_JOB_ITEMS = cdi.FK_JOB_ITEM
join CRM_DOCUMENT_HEADER cdh ON cdi.FK_DOCUMENT_HEADER = cdh.PK_DOCUMENT_HEADER
where cdh.DOCUMENT_TYPE = 1
group by cdi.FK_JOB_ITEM
HTH,
Set