let query = ...// ??? labels.forEach( label => { let codes = get_codes(label); query = query.unionAll( db.selectFrom("data") .select(eb => [ eb.val(label).as('label'), 'data.product', 'data.period', ]) .where("codes", "in", codes) ); }) return await query.execute()
select * from data where length(prodcode) = 3
result = await db.selectFrom("data") .select(['partner_cd', 'reporter_cd', 'product_cd', 'period']) .where((wb) => wb.where("reporter_cd", "=", region1).where("partner_cd", "=", region2), ) .orWhere((wb) => wb.where("partner_cd", "=", region1).where("reporter_cd", "=", region2), ) .execute()
result = await db.selectFrom("data") .select(['partner_cd','reporter_cd']) .where(({ cmpr, or, and, not, exists, selectFrom, val }) => or([ and([ cmpr('reporter_cd', '=', country), cmpr('country_cd', '=', partner) ]), and([ cmpr('country_cd', '=', country), cmpr('reporter_cd', '=', partner) ]), ])) .execute();
Property 'cmpr' does not exist on type 'WhereInterface<From<DB, "data">, "data">'