通过使用顺序而不更改组的顺序

时间:2018-08-15 00:20:27

标签: mysql sql

我正在尝试查找有关子类别的主要类别的数量。我想按每个主要类别按desc进一步排序。目前我的代码

select ShipperID, EmployeeID, count(*)
from orders
group by 1, 2
order by 3 desc

这完全改变了组。如果我能得到每个小组内部订购的帮助,我将非常有责任。

2 个答案:

答案 0 :(得分:2)

我怀疑您只是想将ShipperId作为order by中的第一个键:

select ShipperID, EmployeeID, count(*)
from orders
group by ShipperID, EmployeeID
order by ShipperID, count(*) desc;

答案 1 :(得分:1)

您只需要按照期望的顺序对 for locus in lengtharray: plotn = 1 fig = plt.figure() for filename in lengtharray[locus]: plt.title(filename) idx = np.nonzero(lengtharray[locus][filename]>=MINREADS) # idx = indices of read frequencies >= MINREADS ax = plt.subplot(3, 3, plotn) allele1 = max(idx[0]) testlist = [allele1] plt.bar(idx[0],lengtharray[locus][filename][idx], color='grey') plotn +=1 selected_alleles = [] points = fig.ginput(2) selected_alleles.append(round(points[0][0])) selected_alleles.append(round(points[1][0])) print (selected_alleles) plt.suptitle('Locus = ' + locus) plt.show() 子句中的字段进行除草,如下所示:

order by

您可以查看 this working example hosted at db-fiddle.com

希望对您有帮助。