See below for my query editor
SELECT customer_id, MAX(date_created) AS "Last_purchase" FROM public.accounts_order GROUP BY customer_id;
How will this look as a queryset on my django views?
See below for my query editor
SELECT customer_id, MAX(date_created) AS "Last_purchase" FROM public.accounts_order GROUP BY customer_id;
How will this look as a queryset on my django views?
I believe it would look something like this:
Accounts_order.objects.values('customer_id') \
.annotate(last_created=Max('date_created'))