Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
val qryOutputs = aqlu"""
FOR item IN tblrecipe_details
LET item_por_pieza = (
FOR i IN tbl_claves_por_pieza FILTER i.cve_articulo == item.key_item RETURN i
)
FOR itemPre IN ( LENGTH(item_por_pieza) > 0 ? item_por_pieza: [ { /* no match exists*/ } ] )
LET recipesFechas = (
FOR r IN tblrecipe
FILTER r.fiscal_period == item.fiscal_period &&
r.folio == item.folio &&
r.type_document == item.type_document
RETURN r.date2
)
FOR recipeFech IN ( LENGTH ( recipesFechas ) > 0 ? recipesFechas: [ { /* no match exists*/ } ] )
COLLECT
fecha = recipeFech,
cve_articulo = item.key_item,
descripcion = item.description_item,
presentacion = itemPre.presentacion
AGGREGATE
output = SUM(item.supplied)
SORT fecha, cve_articulo, output DESC
RETURN {
fecha,
cve_articulo,
descripcion,
output,
presentacion,
}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment