Matlab中的SQL:不识别变量

时间:2018-01-28 09:27:44

标签: sql matlab

我在Matlab中有一个查询,其中包含设置日期和间隔的变量:

WindowSize=60;
Day=1;
Month=1;
Year=2005;
ConstituentDate=datestr(datetime(Year,Month,Day),'mm/dd/yyyy');

% My query:
query='SELECT Preis.Isin,  Preis.Datum,  Preis.Preis FROM (SELECT Preis.Isin AS myISIN FROM Constituents INNER JOIN Preis ON Constituents.Isin = Preis.Isin WHERE (Preis.Datum=(select min(Datum) from Preis  WHERE Datum between DateAdd("m",-', num2str(WindowSize) ', #' ConstituentDate '#) and DateAdd("m",-' num2str(WindowSize-1) ', #' ConstituentDate '#)) AND (Constituents.Datum=#' ConstituentDate '#))) AS AvailableISIN INNER JOIN Preis ON AvailableISIN.myISIN = Preis.Isin WHERE (Preis.Datum IN (SELECT max(Preis.Datum) FROM Preis WHERE (Preis.Datum>=DateAdd("m",-' num2str(WindowSize+1) ', #' ConstituentDate '#) AND (Preis.Datum<#' ConstituentDate '#)) GROUP BY MONTH(Preis.Datum), YEAR(Preis.Datum))) ORDER BY  Preis.Datum,Preis.ISIN';

现在我想知道为什么Matlab在我的第一个变量查询(num2str(WindowSize))中显示错误:

Error: Unexpected MATLAB expression.

1 个答案:

答案 0 :(得分:0)

知道了:我必须使用[...]:[' Select... '];

相关问题