22,207
社区成员
发帖
与我相关
我的任务
分享
;with cte as(
select * from table where datediff(dd,date,GETDATE())=1
)
select top 1 A.id, A.date,A.price,(A.price-B.price)/B.price) as 涨幅 from table A
left join cte B on A.id=B.id
where datediff(dd,A.date,GETDATE())=0
order by 涨幅
select a.*
from info a
inner join info b on a.id=b.id and a.日期=dateadd(day,-1,b.日期)
where a.日期='2019-04-18'
order by a.价格-b.价格 desc