且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

T-sql每天获取最小值和最大值

更新时间:2022-12-09 22:25:37

一个简单的group by应该可以工作:

A simple group by should work:

select  cast(price_set_date as date) as [Date]
,       exch_ticker 
,       min(buy_price) as MinPrice
,       max(buy_price) as MaxPrice
from    price_details as p
group by 
        exch_ticker
,       cast(price_set_date as date)

不确定为什么您的示例查询使用自连接.如果有充分的理由,请在您的问题中添加解释.

Not sure why your example query is using a self join. If there's a good reason please add an explanation to your question.