mazole 发表于 2022-11-23 17:00:02

经常遇到获取数据表中列的最小值和最大值,你知道吗?

经常遇到获取数据表中多个列的最小值和最大值,例如:

获取这 4个价格的最小值和最大值:

SELECT

(

http://www.qianxianly.com/data/attachment/forum/20221123/1669194002938_0.png

SELECT min(minPrice)

FROM

(

http://www.qianxianly.com/data/attachment/forum/20221123/1669194002938_1.jpg

VALUES

(IIF(MarketSingleImagetextPrice=0,null,MarketSingleImagetextPrice)),

(IIF(MarketMoreGraphicOnePrice=0,null,MarketMoreGraphicOnePrice)),

http://www.qianxianly.com/data/attachment/forum/20221123/1669194002938_2.jpg

(IIF(MarketMoreGraphicTwoPrice=0,null,MarketMoreGraphicTwoPrice)),

(IIF(MarketMoreGraphicThreePrice=0,null,MarketMoreGraphicThreePrice))

) AS #temp(minPrice)

) AS MinIboPrice

FROM YX_WeChatFlowMode WHERE ShapeID=1 AND FlowID = 1656
页: [1]
查看完整版本: 经常遇到获取数据表中列的最小值和最大值,你知道吗?