Eidur
Eidur
DTDrizzle Team
Created by Eidur on 8/14/2023 in #help
Group by Multiple columns with drizzle
I have a schema that looks rougly like this:
date | location | name | quantity
date | location | name | quantity
I want to groupBy multiple columns(date,location), but I'm not sure if there is a drizzle-way to do it, or should I do a raw query?
const grouped = await d
.select({
location: marketGoods.location,
date: marketGoods.date
quantitySum: sql<number>`sum(${marketGoods.quantity})`,
})
.from(marketGoods)
///idk what to do here
.groupBy(({ date }) => date)
.groupBy(({ good }) => good);
const grouped = await d
.select({
location: marketGoods.location,
date: marketGoods.date
quantitySum: sql<number>`sum(${marketGoods.quantity})`,
})
.from(marketGoods)
///idk what to do here
.groupBy(({ date }) => date)
.groupBy(({ good }) => good);
4 replies