经常遇到获取数据表中多个列的最小值和最大值,例如:
获取这 4个价格的最小值和最大值:
SELECT
(
SELECT min(minPrice)
FROM
(
VALUES
(IIF(MarketSingleImagetextPrice=0,null,MarketSingleImagetextPrice)),
(IIF(MarketMoreGraphicOnePrice=0,null,MarketMoreGraphicOnePrice)),
(IIF(MarketMoreGraphicTwoPrice=0,null,MarketMoreGraphicTwoPrice)),
(IIF(MarketMoreGraphicThreePrice=0,null,MarketMoreGraphicThreePrice))
) AS #temp(minPrice)
) AS MinIboPrice
FROM YX_WeChatFlowMode WHERE ShapeID=1 AND FlowID = 1656