SELECT CMS_ORGANIZATION.ORG_ACTOR_GUID, CMS_EMPLOYMENT.PERIOD_TO AS EventDate, CMS_INDIVIDUAL.FULL_NAME as Name, 'Ceased' AS EventType, 'Overseeing Executive Director' AS TypeOfChange, CMS_ORGANIZATION.REG_NAME
FROM CMS_EMPLOYMENT INNER JOIN CMS_INDIVIDUAL ON CMS_EMPLOYMENT.EMPLOYEE_ACTOR_GUID = CMS_INDIVIDUAL.IND_ACTOR_GUID INNER JOIN
CMS_ROLE_ASSUMED ON CMS_EMPLOYMENT.ROLE_ASSUMED_GUID = CMS_ROLE_ASSUMED.ROLE_ASSUMED_PK INNER JOIN CMS_ORGANIZATION ON CMS_ROLE_ASSUMED.TARGET_ACTOR_GUID = CMS_ORGANIZATION.ORG_ACTOR_GUID INNER JOIN
CMS_MASTER_SETUP ON CMS_EMPLOYMENT.DESIGNATION_GUID = CMS_MASTER_SETUP.MASTER_SETUP_PK
UNION
SELECT CMS_ORGANIZATION.ORG_ACTOR_GUID, CMS_ORG_SHARES_HISTORY.EFFECTIVE_DATE AS EventDate, CMS_MASTER_SETUP.Description as Currency, CONVERT(varchar(50), CAST(CMS_ORG_SHARES.AUTHORIZED_CAP_AMOUNT AS money), 1),
'Changed to ' AS EventType, 'Share Capital (Authorized)' AS TypeOfChange, CMS_ORGANIZATION.REG_NAME
FROM CMS_ORGANIZATION INNER JOIN CMS_ORG_SHARES ON CMS_ORGANIZATION.ORG_ACTOR_GUID = CMS_ORG_SHARES.ORG_ACTOR_GUID INNER JOIN CMS_ORG_SHARES_HISTORY ON CMS_ORG_SHARES.ORG_SHARES_PK = CMS_ORG_SHARES_HISTORY.ORG_SHARES_GUID INNER JOIN CMS_MASTER_SETUP ON CMS_ORGANIZATION.CURRENCY_GUID = CMS_MASTER_SETUP.MASTER_SETUP_PK
UNION
SELECT CMS_ORGANIZATION.ORG_ACTOR_GUID, CMS_ORG_SHARES_HISTORY.EFFECTIVE_DATE AS EventDate, CONVERT(varchar(50), CAST(CMS_ORG_SHARES.PAID_UP_CAP_AMOUNT AS money), 1),
'Changed to' AS EventType, 'Share Capital (Paid Up)' AS TypeOfChange, CMS_ORGANIZATION.REG_NAME
FROM CMS_ORGANIZATION INNER JOIN CMS_ORG_SHARES ON CMS_ORGANIZATION.ORG_ACTOR_GUID = CMS_ORG_SHARES.ORG_ACTOR_GUID INNER JOIN
CMS_ORG_SHARES_HISTORY ON CMS_ORG_SHARES.ORG_SHARES_PK = CMS_ORG_SHARES_HISTORY.ORG_SHARES_GUID
我已經得到了這個錯誤:
「的所有查詢使用UNION合併,交叉或EXCEPT運營商必須在其目標列表中的表達式的數目相等。」在第一行。請問如何查詢「CMS_MASTER_SETUP.Description作爲貨幣,CONVERT(varchar(50),CAST(CMS_ORG_SHARES.AUTHORIZED_CAP_AMOUNT AS貨幣),1)」在名稱列下,但都作爲貨幣SQL服務器 - 聯盟
它現在也發生在我身上,你可以做一個簡單的+字符。 CMS_MASTER_SETUP.Description +','+ CONVERT(varchar(50),CAST(CMS_ORG_SHARES.AUTHORIZED_CAP_AMOUNT AS貨幣),1)貨幣 – luxdvie
不可能包含空白佔位符,因爲第一個查詢的數據與第二個查詢的數據不同一。例如,第一個查詢沒有貨幣值(NULL)。我可能需要運行另一個查詢,例如,如果未插入第二個查詢中的貨幣,我會設置貨幣,之後會自動轉換爲「USD」。但如果我這樣做,第一個和第三個查詢將有貨幣「美元」,如果你知道我的意思是 –