需要转换查询帮助 [英] Transform Query Help required
问题描述
您好我有一个存储旅行详情的数据库。有一个存储基本旅行信息的父表和一个存储要访问的国家信息的子表。
我目前的查询是:
TRANSFORM [测试孩子]。[到达国家] AS国家
SELECT [测试门票] .Locator
来自[测试门票] INNER JOIN [测试孩子] ON [测试门票] .Locator = [测试孩子] .Locator
GROUP BY [测试门票] .Locator
PIVOT [测试孩子]。[到达国家];
问题是子表中的所有国家/地区都显示为标题,我想要的是将10列Country1到Country10显示为列标题,并在数据中显示国家/地区名称。
我确定这是一个简单的解决方案,但我无法想到它。任何帮助将不胜感激。
-Kevin。
Hi I have a database storing trip details. There''s a parent table which stores the basic trip information and a child table that stores the countries to be visited information.
The query I have at the moment is:
TRANSFORM [Test Child].[Arrival Country] AS country
SELECT [Test Tickets].Locator
FROM [Test Tickets] INNER JOIN [Test Child] ON [Test Tickets].Locator = [Test Child].Locator
GROUP BY [Test Tickets].Locator
PIVOT [Test Child].[Arrival Country];
The problem is that all the countries in the child table are shown as headings and what I want is to have 10 columns Country1 to Country10 displayed as column headings with the country name in the data.
I''m sure there''s a simple solution but I can''t think of it. Any help will be much appreciated.
-Kevin.
推荐答案
您是在谈论类似的事情:
Are you talking about something that looks like:
您是在谈论类似的内容:
Are you talking about something that looks like:
好,你需要两个查询。一个用于指定等级。到每个国家旅行。然后是交叉表。如果我们怀疑的是什么顺序并不重要,那么你可以排名。按国家名称。否则你可能会在访问日期排名。
Well, you''ll need two queries. One to assign a "rank" to each country for a trip. And then the crosstab. If it doesn''t matter what order they''re in, which I doubt, then you can "rank" by country name. Otherwise you''ll probably be ranking on the date of the visit.
这篇关于需要转换查询帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!