Row_number中的Order By无法正常工作

时间:2017-05-25 20:28:38

标签: sql function row-number

我有Order by函数用于获取最新记录,但函数中的SELECT *, ROW_NUMBER() OVER(PARTITION BY EmployeeID, DepartmentID ORDER BY PayDate, WorkDate desc) AS CurrentFlag FROM test 似乎不起作用。不确定我做错了什么。

EmployeeID | DepartmentID | Balance | PayDate  |  WorkDate   | CurrentFlag
123          1              200       1/3/2017    12/22/2016   1
123          1              300       1/3/2017    12/23/2016   2
123          1              500       1/5/2017    12/24/2016   3

结果表的示例:

EmployeeID | DepartmentID | Balance | PayDate  |  WorkDate   | CurrentFlag
123          1              200       1/3/2017    12/22/2016   3
123          1              300       1/3/2017    12/23/2016   2
123          1              500       1/5/2017    12/24/2016   1

我应该得到什么:

ROW_NUMBER

我不确定我在PayDate函数中做错了什么。我按WorkDate然后按CurrentFlag = 1降序排序,因此我应该WorkDate获取最新的12/24/2016 def gauss(mean,sigma): from random import uniform from math import sqrt,log,pi,cos a=uniform(0,1) b=uniform(0,1) x=sqrt(-2*log(a))*cos(2*pi*b) return(x) def bruiter(image): from matplotlib.pyplot import imread if len(image.shape)==3 : a,b,c=image.shape for i in range(a): for j in range(b): image[i][j] += [gauss(0.5,0.01),gauss(0.5,0.01),gauss(0.5,0.01)] elif len(image.shape)==2 : a,b= image.shape for i in range(a): for j in range(b): image[i][j] += gauss(0.01)*(1/255) return(image) 。我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:3)

每个~/R-3.4.0$ ./configure ... configure: error: libcurl >= 7.22.0 library and headers are required with support for https ~/R-3.4.0$ curl -V curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3 项都是单独处理的,除非另有说明,否则他们正在考虑ORDER BY

您似乎希望这两个项目都是ASC,请尝试:

DESC