业务场景:
两个表,需要查询表1但是表1里面的记录在表2有关联。
查询命令如下:
- sub="select sum(hostnumber) from snapserver where fileid=snapshot.fileid group by snapserver.fileid";
- result = self.extra(select={'a':sub}).values('a','fileid','filename','author','modifynum','lastpl','lastmt','score').order_by('-score')[:10]
阅读(3190) | 评论(0) | 转发(0) |