我尝试从不同行的startdate
中减去enddate
,但仅针对相同的代码。
例如:
startdate
C002 (2012-07-01)
减去行enddate
中的C002 (2012-06-30)
row code startdate enddate
1 C002 2011-07-01 00:00:00.000 2012-06-30 00:00:00.000
2 C002 2012-07-01 00:00:00.000 2013-06-30 00:00:00.000
3 C003 2011-07-01 00:00:00.000 2012-06-30 00:00:00.000
4 C003 2012-07-01 00:00:00.000 2013-06-30 00:00:00.000
__atribute__((noinline))
。
我该怎么做呢?
x.labelFormatter = nil;
答案 0 :(得分:0)
select max(row),code,datediff(day,max(startdate),min(enddate)) as ouputtt
from table
group by
code
答案 1 :(得分:0)
试试这个 -
Select x.code, y.startdate-x.enddate
From table1 x left outer join table1 y on
X.code=Y.code
Where
X.enddate<y.startdate
答案 2 :(得分:0)
您可以使用此查询,该请求将请求的值添加为附加列:
select row, code, startdate, enddate,
datediff('d', lag(enddate) over (partition by code order by row1), startdate) df
from mytable