Hi,
after sql usage, i am getting use to N1QL. But i would like to write sub query like above. When i want to try this, i usually take this error :
[
** {**
** “code”: 5010,**
** “msg”: “Error evaluating projection. - cause: FROM in correlated subquery must have USE KEYS clause: FROM mybucket.”**
** }**
]
this is my query. How can i change for N1QL ?
SELECT crmtransaction.rec_id
,crmtransaction.transactionday_id
,crmtransaction.explanation
,crmtransaction.transactiontimeitem_id
,crmtransaction.cast_id
,crmtransaction.transactionstatus
,erpcast.employeecode
,erpcast.employeename
,erpcast.employeesurname
,erpcast.IdCardNo
,(SELECT count(erpscaneitem) scenecount FROM mybucket
erpscaneitem JOIN mybucket
cast1 ON KEYS erpscaneitem.cast_id WHERE erpscaneitem.type = “ErpSceneItem” and erpscaneitem.isdeleted = false and erpscaneitem.isprocessed = false and cast1.isdeleted = false and cast1.rec_id = crmtransaction.cast_id GROUP BY erpscaneitem.cast_id) scenecount
FROM
mybucket
crmtransaction
LEFT JOIN mybucket
erpcast ON KEYS crmtransaction.cast_id
WHERE crmtransaction.type = "CrmTransaction"
AND crmtransaction.transactionstatus IN [0,1]
AND crmtransaction.inuse = True
AND crmtransaction.isdeleted = False
AND crmtransaction.cast_id IS NOT NULL
ORDER BY crmtransaction.transactionday_id ASC , crmtransaction.transactiontimeitem_id ASC , erpcast.employeename ASC , erpcast.employeecode ASC
Thanks for help