select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by substr(ny,1,4),gyrs,ny-rownum order by kssj;
#4
求帮助 实在想不出来了
#5
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by gyrs,ny-rownum order by kssj;
这样更省事,ny-rownum已经包含substr(ny,1,4)了
#6
这有一个,但是还有一个小问题
select min(ny) as kssj,max(ny) as zzsj,gyrs from(
select ny,gyrs,r,row_number() over(partition by gyrs,r order by ny)-rownum d from(
select ny,gyrs,(select r from (select kssj,zzsj,rownum r from t2) where t1.ny<=zzsj and t1.ny>=kssj) r from t1 order by ny
)
)
group by gyrs,r,d
order by kssj asc;
结果如下:
最后的那个201605没有设置为空
#7
解决了该问题,万分感谢~
#8
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by substr(ny,1,4),gyrs,ny-rownum order by kssj;
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by gyrs,ny-rownum order by kssj;
这样更省事,ny-rownum已经包含substr(ny,1,4)了
解决了该问题,万分感谢~
#9
这有一个,但是还有一个小问题
select min(ny) as kssj,max(ny) as zzsj,gyrs from(
select ny,gyrs,r,row_number() over(partition by gyrs,r order by ny)-rownum d from(
select ny,gyrs,(select r from (select kssj,zzsj,rownum r from t2) where t1.ny<=zzsj and t1.ny>=kssj) r from t1 order by ny
)
)
group by gyrs,r,d
order by kssj asc;
结果如下:
最后的那个201605没有设置为空
解决了该问题,万分感谢
#1
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from 表1 group by substr(ny,1,4),gyrs order by kssj;
#2
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from 表1 group by substr(ny,1,4),gyrs order by kssj;
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by substr(ny,1,4),gyrs,ny-rownum order by kssj;
#4
求帮助 实在想不出来了
#5
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by substr(ny,1,4),gyrs,ny-rownum order by kssj;
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by gyrs,ny-rownum order by kssj;
这样更省事,ny-rownum已经包含substr(ny,1,4)了
#6
这有一个,但是还有一个小问题
select min(ny) as kssj,max(ny) as zzsj,gyrs from(
select ny,gyrs,r,row_number() over(partition by gyrs,r order by ny)-rownum d from(
select ny,gyrs,(select r from (select kssj,zzsj,rownum r from t2) where t1.ny<=zzsj and t1.ny>=kssj) r from t1 order by ny
)
)
group by gyrs,r,d
order by kssj asc;
结果如下:
最后的那个201605没有设置为空
#7
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by substr(ny,1,4),gyrs,ny-rownum order by kssj;
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by gyrs,ny-rownum order by kssj;
这样更省事,ny-rownum已经包含substr(ny,1,4)了
解决了该问题,万分感谢~
#8
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by substr(ny,1,4),gyrs,ny-rownum order by kssj;
select MIN(NY) kssj,MAX(NY) zzsj,gyrs from (select * from 表1 order by gyrs,ny) group by gyrs,ny-rownum order by kssj;
这样更省事,ny-rownum已经包含substr(ny,1,4)了
解决了该问题,万分感谢~
#9
这有一个,但是还有一个小问题
select min(ny) as kssj,max(ny) as zzsj,gyrs from(
select ny,gyrs,r,row_number() over(partition by gyrs,r order by ny)-rownum d from(
select ny,gyrs,(select r from (select kssj,zzsj,rownum r from t2) where t1.ny<=zzsj and t1.ny>=kssj) r from t1 order by ny
)
)
group by gyrs,r,d
order by kssj asc;