mssql in c# -- looking for a better way
SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
	case-- Market
		WHEN Market < LiFo AND Market < Wgtd_Avg THEN Market
		WHEN LiFo < Wgtd_Avg THEN LiFo
		ELSE Wgtd_Avg
	end
 as LeastOfThree
FROM VF_CasINV_Cost
--WHERE Market > 0 and LiFo >0 and Wgtd_Avg > 0

SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
(
	case
		WHEN LiFo < Wgtd_Avg THEN LiFo
		ELSE Wgtd_Avg
	end
) as LeastOfThree
FROM VF_CasINV_Cost
WHERE LiFo >0 and Wgtd_Avg > 0 and (Market = 0)

SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
(
	case
		WHEN Wgtd_Avg < Market THEN Wgtd_Avg
		ELSE Market
	end
) as LeastOfThree
FROM VF_CasINV_Cost
WHERE Market >0 and Wgtd_Avg > 0 and (LiFo = 0)

SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
(
	case
		WHEN LiFo < Market THEN LiFo
		ELSE Market
	end
) as LeastOfThree
FROM VF_CasINV_Cost
WHERE Market > 0 and LiFo > 0 and Wgtd_Avg = 0-- and (LeastOfThree = 0)

mssql in c# -- looking for a better way
===

SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
	case-- Market
		WHEN Market < LiFo AND Market < Wgtd_Avg THEN Market
		WHEN LiFo < Wgtd_Avg THEN LiFo
		ELSE Wgtd_Avg
	end
 as LeastOfThree
FROM VF_CasINV_Cost
--WHERE Market > 0 and LiFo >0 and Wgtd_Avg > 0

SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
(
	case
		WHEN LiFo < Wgtd_Avg THEN LiFo
		ELSE Wgtd_Avg
	end
) as LeastOfThree
FROM VF_CasINV_Cost
WHERE LiFo >0 and Wgtd_Avg > 0 and (Market = 0)

SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
(
	case
		WHEN Wgtd_Avg < Market THEN Wgtd_Avg
		ELSE Market
	end
) as LeastOfThree
FROM VF_CasINV_Cost
WHERE Market >0 and Wgtd_Avg > 0 and (LiFo = 0)

SELECT Market, LiFo, Wgtd_Avg, LeastOfThree,
(
	case
		WHEN LiFo < Market THEN LiFo
		ELSE Market
	end
) as LeastOfThree
FROM VF_CasINV_Cost
WHERE Market > 0 and LiFo > 0 and Wgtd_Avg = 0-- and (LeastOfThree = 0)
