在 SQL TRANSFORM 查询中指定列的调用函数 [英] Call function for specifying columns in SQL TRANSFORM query
问题描述
这是我的查询:
PARAMETERS ...
TRANSFORM ...
SELECT ...
...
PIVOT Mytable.type In ("Other","Info");
这是一个交叉查询,我需要用这一行设置所有列标题:PIVOT Mytable.type In ("Other","Info")
现在我已经硬编码了标题、其他和信息.
This is a cross query and I need to set all the column headings with this row: PIVOT Mytable.type In ("Other","Info")
and now I have hard-coded the headings, Other and Info.
但我想动态地做到这一点.所以我想要做的是调用一个返回我需要的所有标题的 vba 函数.
But I want to do this dynamically. So what I want to do is to call a vba-function that returns all the headings I need.
像这样:
PIVOT Mytable.type In (myVbaFunction());
所以我的问题是:如何在 sql-query 中调用 vba 函数?
So my question is: How to call a vba-function inside the sql-query?
推荐答案
是的,这是可能的.
但是,我认为 WHERE IN (...)
是不可能的.
Yes, it is possible.
However, I don't think it's possible with WHERE IN (...)
.
这里是一个普通的 WHERE
查询示例:
Here is an example for a normal WHERE
query:
Public Function Test() As String
Test = "Smith"
End Function
...然后:
SELECT * FROM Users WHERE Name = Test();
它有效,只要函数只返回一个值.
但我认为不可能让您的函数返回诸如Smith, Miller"之类的内容并使用以下内容:
It works, as long as the function only returns one value.
But I think it's not possible to let your function return something like "Smith, Miller" and use that like:
SELECT * FROM Users WHERE Name In (Test());
(至少我不知道怎么做)
(at least I don't know how to do it)
这篇关于在 SQL TRANSFORM 查询中指定列的调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!