1
select語句這是我的查詢集:Django的 - 裏面ORDER_BY
most_event_wins = UserEvent.objects.filter(position=1)\
.values('user', 'user__first_name', 'user__last_name').annotate(wins=Count('user'))\
.order_by('-wins', '(select max(created) as d from users_userevent as s '
'where s.user_id=users_userevent.user_id and position=1)')
,我發現了以下錯誤:
Invalid order_by arguments: ['(select max(created) as d from users_userevent as s where s.user_id=users_userevent.user_id and position=1)']
我可以使用SELECT語句中的ORDER_BY裏面?如果沒有任何解決方案的情況下。