調査のデータをSQLServerデータベースに保存しており、Tableauを使用して分析しています。Tableausの癖の1つは、このリンクが示すように、特定の形式のデータが必要なことです。
ユニオンを使用する彼らの方法は機能しますが、私のデータは100の質問に分散しており、そのうちのいくつかには10のオプションがあります。UNION
これにより、編集がほぼ不可能になる巨大なSQLステートメントが作成されます。
私の計画は、変更する必要のある各質問と結合を実行してから、変更する必要のない他のデータと内部結合することでしたが、結合の結果、最初のselectステートメントフィールドのみが返されます。
これが参考のためのユニオンステートメントです
select
[Survey].[SurveyId] AS [SurveyId],
[HumanCapital_Issues].[DisclosureResponsibility_Importance] AS [importance],
'Disclosure Responsibility' as [HCI_Importance]
FROM [Survey].[Survey] [Survey]
INNER JOIN [Survey].[HumanCapital_Issues] [HumanCapital_Issues] ON ([survey].[SurveyId] = [HumanCapital_Issues].[SurveyId])
union
select
[Survey].[SurveyId] AS [SurveyId],
[HumanCapital_Issues].[DevelopingSkills_Importance] AS [importance],
'Developing skills' as [HCI_Importance]
FROM [Survey].[Survey] [Survey]
INNER JOIN [Survey].[HumanCapital_Issues] [HumanCapital_Issues] ON ([Survey].[SurveyId] = [HumanCapital_Issues].[SurveyId])
SELECT [Survey].[SurveyId] AS [Survey_SurveyId],
[Survey].[Year] AS [Year],
[Survey].[FinancialInstitutionCode] AS [FinancialInstitutionCode],
[Survey].[DeletionCode] AS [DeletionCode],
[Survey].[SalaryOnly] AS [SalaryOnly],
[FinancialInstitution].[FinancialInstitutionCode] AS [FinancialInstitution_FinancialInstitutionCode],
[FinancialInstitution].[Name] AS [Name],
[FinancialInstitution].[FDIC] AS [FDIC],
[FinancialInstitution].[Address_Street1] AS [Address_Street1],
[FinancialInstitution].[Address_Street2] AS [Address_Street2],
[FinancialInstitution].[Address_City] AS [Address_City],
[FinancialInstitution].[Address_State] AS [Address_State],
[FinancialInstitution].[Address_Zip] AS [Address_Zip],
[FinancialInstitution].[Address_County] AS [Address_County],
[FinancialInstitution].[ParentCompany] AS [ParentCompany],
[FinancialInstitution].[FDICBHC] AS [FDICBHC],
[FinancialInstitution].[OwnershipStructureCode] AS [OwnershipStructureCode],
[FinancialInstitution].[Employees_FullTimeEquivalent] AS [Employees_FullTimeEquivalent],
[FinancialInstitution].[Employees_FullTime] AS [Employees_FullTime],
[FinancialInstitution].[Employees_PartTime] AS [Employees_PartTime],
[FinancialInstitution].[Branches_FullService] AS [Branches_FullService],
[FinancialInstitution].[Branches_InStore] AS [Branches_InStore],
[FinancialInstitution].[Brances_LimitedService] AS [Brances_LimitedService],
[FinancialInstitution].[Headquarters_Population] AS [Headquarters_Population],
[FinancialInstitution].[LargestCity_Population] AS [LargestCity_Population],
[FinancialInstitution].[Assets] AS [Assets],
[FinancialInstitution].[Deposits] AS [Deposits],
[FinancialInstitution].[TARP_Participated] AS [TARP_Participated],
[FinancialInstitution].[TARP_CausedConcern] AS [TARP_CausedConcern],
[FinancialInstitution].[TARP_RequiredChanges] AS [TARP_RequiredChanges],
[FinancialInstitution].[RegionCode] AS [RegionCode],
[HumanCapital_Issues].[SurveyId] AS [HumanCapital_Issues_SurveyId],
[HumanCapital_Issues].[DisclosureResponsibility_Concern] AS [DisclosureResponsibility_Concern],
[HumanCapital_Issues].[DevelopingSkills_Concern] AS [DevelopingSkills_Concern],
[HumanCapital_Issues].[MotivatingPerformance_Concern] AS [MotivatingPerformance_Concern],
[HumanCapital_Issues].[Reorganizations_Concern] AS [Reorganizations_Concern],
[HumanCapital_Issues].[Hiring_Concern] AS [Hiring_Concern],
[HumanCapital_Issues].[Retention_Concern] AS [Retention_Concern],
[HumanCapital_Issues].[ContainingCosts_Concern] AS [ContainingCosts_Concern],
[HumanCapital_Issues].[ManagingRetirements_Concern] AS [ManagingRetirements_Concern],
[HumanCapital_Issues].[SalesCulture_Concern] AS [SalesCulture_Concern],
[HumanCapital_Issues].[DevelopingLeaders_Concern] AS [DevelopingLeaders_Concern],
[HumanCapital_Issues].[Other_Description] AS [Other_Description],
[HumanCapital_Issues].[Other_Concern] AS [Other_Concern]
FROM
[Survey].[Survey] [Survey]
INNER JOIN
[Profile].[FinancialInstitution] [FinancialInstitution] ON ([Survey].[SurveyId] = [FinancialInstitution].[FinancialInstitutionCode])
INNER JOIN
[Survey].[HumanCapital_Issues] [HumanCapital_Issues] ON ([Survey].[SurveyId] = [HumanCapital_Issues].[SurveyId])
ユニオンを実行してから別のselectステートメントと結合する「簡単な方法」はありますか?