[CDB::fetch_array] SQLSTATE: 42S02, code: 208
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name 'LUNA2_LOGDB.dbo.TB_ITEM_LOG_20181022'.
QUERY:
IF 1 = 1 --EXISTS(SELECT NULL FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG = 'LUNA2_LOGDB' AND TABLE_NAME = 'TB_ITEM_LOG_20181022') BEGIN WITH CTE_Rank( [CharacterIdx], [CharacterName], [TotalSellPrice], [TotalDropMoney], [TotalQuestMoney] ) AS( SELECT A.[ToChrIdx] [CharacterIdx] ,MAX(A.[ToChrName]) [CharacterName] ,SUM(B.SellPrice*CASE WHEN A.ItemDur = 0 THEN 1 ELSE A.ItemDur END) [TotalSellPrice] ,(SELECT ISNULL(SUM([changeValue]),0) FROM [LUNA2_LOGDB].[dbo].[TB_MONEYLOGWRONG] WHERE LogType = 3 AND REPLACE(CONVERT(VARCHAR(10), LogDate, 111), '/', '') = '20181022' AND charno = A.ToChrIdx) [TotalDropMoney] ,(SELECT ISNULL(SUM([changeValue]),0) FROM [LUNA2_LOGDB].[dbo].[TB_MONEYLOG] WHERE LogType = 12 AND REPLACE(CONVERT(VARCHAR(10), LogDate, 111), '/', '') = '20181022' AND charno = A.ToChrIdx) [TotalQuestMoney] FROM [LUNA2_LOGDB].[dbo].[TB_ITEM_LOG_20181022] A LEFT JOIN [LUNA2_RESRCDB].[dbo].[TB_BIN_ItemList] B ON A.[ItemIdx] = B.[ItemIdx] WHERE A.[LogType] IN (203, 213) GROUP BY A.[ToChrIdx] ) SELECT TOP 100 [CharacterIdx] ,[CharacterName] ,[TotalSellPrice] ,[TotalDropMoney] ,[TotalQuestMoney] ,[TotalSellPrice]+[TotalDropMoney]+[TotalQuestMoney] [TotalSumMoney] FROM CTE_Rank ORDER BY TotalSumMoney DESC END ELSE SELECT 0