我在这里多次看到此错误消息,但我没有从中获得针对我的特定问题的解决方案(可能是因为我不是 sql 专家),所以请原谅我向同一个问题发布问题错误。
这是我要执行的查询:
SELECT DISTINCT U.FB_UserId
, U.Id AS GameUserID
, U.FbLocale
, U.FbGender
, U.FbBirthday
, U.RegistredAt
, U.LoginCount
, U.PlayCount
, U.MarketGroupId
, (SELECT COUNT(C.PriceFbCredits)
WHERE UserID = U.Id) AS Payments
, (SELECT SUM(CASE WHEN C.PriceFbCredits = 13 THEN 1 END)
WHERE UserID = U.Id) AS P13
, (SELECT SUM(CASE WHEN C.PriceFbCredits = 52 THEN 1 END)
WHERE UserID = U.Id) AS P52
, (SELECT SUM(CASE WHEN C.PriceFbCredits = 130 THEN 1 END)
WHERE UserID = U.Id) AS P130
FROM [dbo].[User] AS U WITH (NOLOCK) INNER JOIN [dbo].[FbCreditsCallback] AS C WITH (NOLOCK) ON C.UserId = U.Id
如果我这样做,我会收到错误消息。好的,我知道这意味着什么,我有点明白该怎么做,但我认为如果我这样做并没有给我想要的结果......我想要一些特定的数据userid
。一些数据需要求和,其中一些需要计数,并且在结果列表中每个 id 应该只出现一次。
现在这是有趣的事情(对我来说)。如果我像这样编写内部 SELECT-Queries,我不会收到错误消息。但不知道返回的数据是否正确:
, (SELECT COUNT(PriceFbCredits)
FROM [dbo].[FbCreditsCallback]
WHERE UserID = U.Id) AS Payments
...说实话,我有点迷失了方向,我希望能得到一些帮助。