search: elegir el que mas stock tenga

This commit is contained in:
Cat /dev/Nulo 2024-01-05 15:41:19 -03:00
parent 5754214498
commit f645607adf

View file

@ -11,7 +11,7 @@ export const load: PageServerLoad = async ({ url }) => {
join precios p on p.ean = f.ean
where f.name match ${`"${query}"`}
group by p.ean
having max(p.fetched_at)
having max(p.fetched_at) and max(p.in_stock)
order by p.in_stock desc;`;
results = db.all(sqlQuery);
}