0
我有一些問題:關於GROUP BY在Django
# models.py
class someinfo(models.Model):
data1 = models.BigIntegerField(verbose_name='data1')
data2 = models.BigIntegerField(verbose_name='data2')
data_pubdate = models.DateTimeField(default=timezone.now, verbose_name='data_pubdate')
people = models.ForeignKey(Drive, on_delete=models.CASCADE, verbose_name='people')
數據表有:
# row data
data1 data2 data_pubdate people
7777129 23232 2017-05-18 05:04:08.377 9
158160 4573279 2017-05-18 05:04:08.737 8
158200 5709307 2017-05-18 05:04:08.787 6
10073 11612 2017-05-18 05:04:19.727 6
2458 5245466 2017-05-18 05:04:19.727 4
2458 5245466 2017-05-18 05:04:19.724 4
14879 9727 2017-05-18 05:04:19.897 7
...etc
我要從新data_pubdate在每個人的選擇data1和data2的,像這樣的表:
# select data
data1 data2 data_pubdate people
7777129 23232 2017-05-18 05:04:08.377 9
158160 4573279 2017-05-18 05:04:08.737 8
10073 11612 2017-05-18 05:04:19.727 6
2458 5245466 2017-05-18 05:04:19.727 4
14879 9727 2017-05-18 05:04:19.897 7
那麼...我該怎麼辦?
P.S. Django的版本是 「1.10」,數據庫是 「MSSQL Server 2012的」
你的建議是美妙的有用。我會試着去理解這個原則。 – ice916