刚刚发现联合查询。我正在尝试将链接到我的数据库的 Excel 表转换为普通的选择查询。我一直在阅读这个论坛上以前的帖子,并且已经设法到达那里。我无法解决的是,如何将列标题包含在查询正文中。
使用的代码
SELECT DailyClosePrices.Pricedate, DailyClosePrices AFI As ClosePrice
FROM DailyClosePrices
UNION
SELECT DailyClosePrices.Pricedate, DailyClosePrices ARG
FROM DailyClosePrices
UNION
SELECT DailyClosePrices.Pricedate, DailyClosePrices A200
FROM DailyClosePrices
附表和查询示例,显示当前结果和所需结果。任何帮助将不胜感激。
表和查询示例 (https://i.sstatic.net/3iRM0tlD.png)
参见示例
SELECT DailyClosePrices.Pricedate, "AFI" as FuncCode, AFI As ClosePrice
FROM DailyClosePrices
UNION
SELECT DailyClosePrices.Pricedate, "ARG" as FuncCode, ARG as ClosePrices
FROM DailyClosePrices
UNION
SELECT DailyClosePrices.Pricedate, "A200" as FuncCode,A200 as ClosePrices
FROM DailyClosePrices