SELECT CD.CartId
,PR.Name
,PR.SKU
,CD.Quantity
,CD.Price
,CD.Total
,CD.IsAddedFromWidget
,CD.WidgetSlotLabel
,CD.AddToCartDate
,CO.UpdatedDate AS [CheckoutDate]
,CD.PurchaseDate {from [Tracking].[CartDetail] CD
INNER JOIN [Tracking].[Cart] C ON CD.CartId = C.Id
INNER JOIN [Tracking].[Product] PR ON CD.ProductId = PR.Id
INNER JOIN [Tracking].[Checkout] CO ON C.$NODE_ID = CO.$TO_ID
WHERE C.WebsiteId = @Websited
AND C.STATUS = 20
AND CD.PurchaseDate >= @FromDate
AND CD.PurchaseDate <= @ToDate
ORDER BY CD.PurchaseDate DESC
,CD.CartId DESC}
However, I am getting the error:
然而,我得到了一个错误:
Must declare the scalar variable "@WebsiteID".
必须声明标量变量“@WebsiteID”。
1 个解决方案
#1
2
Here is an example of what your declarations might look like.
下面是您的声明的示例。
DECLARE @WebsiteID uniqueidentifier = NEWID()
,@FromDate DATETIME = GETDATE() - 1
,@ToDate DATETIME = GETDATE()
SELECT CD.CartId
,PR.Name
,PR.SKU
,CD.Quantity
,CD.Price
,CD.Total
,CD.IsAddedFromWidget
,CD.WidgetSlotLabel
,CD.AddToCartDate
,CO.UpdatedDate AS [CheckoutDate]
,CD.PurchaseDate
FROM [Tracking].[CartDetail] CD
INNER JOIN [Tracking].[Cart] C ON CD.CartId = C.Id
INNER JOIN [Tracking].[Product] PR ON CD.ProductId = PR.Id
INNER JOIN [Tracking].[Checkout] CO ON C.$NODE_ID = CO.$TO_ID
WHERE C.WebsiteId = @WebsiteID
AND C.STATUS = 20
AND CD.PurchaseDate >= @FromDate
AND CD.PurchaseDate <= @ToDate
ORDER BY CD.PurchaseDate DESC
,CD.CartId DESC
Also, it appears to me that @Websited
is a typo, so I've used @WebsiteID
.
而且,在我看来,@Websited是一个错误,所以我使用了@WebsiteID。
I've also removed the invalid { }
braces from your code.
我还从您的代码中删除了无效的{}括号。
Additionally, the column names $NODE_ID
and $TO_ID
look a little weird to me. (The usage of $
is what I am talking about).
另外,列名$NODE_ID和$TO_ID在我看来有点奇怪。(我说的是$的用法)。
#1
2
Here is an example of what your declarations might look like.
下面是您的声明的示例。
DECLARE @WebsiteID uniqueidentifier = NEWID()
,@FromDate DATETIME = GETDATE() - 1
,@ToDate DATETIME = GETDATE()
SELECT CD.CartId
,PR.Name
,PR.SKU
,CD.Quantity
,CD.Price
,CD.Total
,CD.IsAddedFromWidget
,CD.WidgetSlotLabel
,CD.AddToCartDate
,CO.UpdatedDate AS [CheckoutDate]
,CD.PurchaseDate
FROM [Tracking].[CartDetail] CD
INNER JOIN [Tracking].[Cart] C ON CD.CartId = C.Id
INNER JOIN [Tracking].[Product] PR ON CD.ProductId = PR.Id
INNER JOIN [Tracking].[Checkout] CO ON C.$NODE_ID = CO.$TO_ID
WHERE C.WebsiteId = @WebsiteID
AND C.STATUS = 20
AND CD.PurchaseDate >= @FromDate
AND CD.PurchaseDate <= @ToDate
ORDER BY CD.PurchaseDate DESC
,CD.CartId DESC
Also, it appears to me that @Websited
is a typo, so I've used @WebsiteID
.
而且,在我看来,@Websited是一个错误,所以我使用了@WebsiteID。
I've also removed the invalid { }
braces from your code.
我还从您的代码中删除了无效的{}括号。
Additionally, the column names $NODE_ID
and $TO_ID
look a little weird to me. (The usage of $
is what I am talking about).
另外,列名$NODE_ID和$TO_ID在我看来有点奇怪。(我说的是$的用法)。