Created
May 26, 2021 00:19
-
-
Save elyphas/9d729450efedaae5d71229ef090e487d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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