0
我有一个计算列的视图,现在我需要强制计算列为“not null
”用于lightswitch。在视图中定义一个计算列为非空
我试图cast()
,但我仍然不能得到计算列是“not null
” 这可能吗?
这是我的SQL:
SELECT dbo.Nop_Manufacturer.Name,
CAST(SUM(dbo.Nop_OrderProductVariant.PriceExclTax) AS INT) AS
SALES,
CAST(MONTH(dbo.Nop_Order.PaidDate) AS INT) AS
paid_month,
CAST(YEAR(dbo.Nop_Order.PaidDate) AS INT) AS
paid_year,
CAST(COUNT(dbo.Nop_OrderProductVariant.OrderProductVariantID) AS INT)AS
num_prod_sold
FROM dbo.Nop_ProductVariant
INNER JOIN dbo.Nop_OrderProductVariant
ON dbo.Nop_ProductVariant.ProductVariantId =
dbo.Nop_OrderProductVariant.ProductVariantID
INNER JOIN dbo.Nop_Product
ON dbo.Nop_ProductVariant.ProductID = dbo.Nop_Product.ProductId
INNER JOIN dbo.Nop_Product_Manufacturer_Mapping
INNER JOIN dbo.Nop_Manufacturer
ON dbo.Nop_Product_Manufacturer_Mapping.ManufacturerID =
dbo.Nop_Manufacturer.ManufacturerID
ON dbo.Nop_Product.ProductId =
dbo.Nop_Product_Manufacturer_Mapping.ProductID
INNER JOIN dbo.Nop_Order
ON dbo.Nop_OrderProductVariant.OrderID = dbo.Nop_Order.OrderID
WHERE (NOT (dbo.Nop_Order.PaidDate IS NULL))
GROUP BY dbo.Nop_Manufacturer.Name,
MONTH(dbo.Nop_Order.PaidDate),
YEAR(dbo.Nop_Order.PaidDate)
非常好,我一直在努力寻找同样的东西。我正在使用我最喜欢的COALESCE,但只有ISNULL将列设置为NOT NULL,至少在表中。感谢分享。 –