SQL TOP & Variable Issue

Please report bugs in this group. We will maybe populate a list of known bugs with a possibly modified description at a later time.

Moderator: Support

Post Reply
zoidberg
Posts: 10
Joined: 22 Jan 2013, 11:14

SQL TOP & Variable Issue

Post by zoidberg » 29 Jan 2018, 09:15

Hi guys,

I have a small issue with using a SQL script node variable to restrict the amount of selected datasets:
Here is my query:

SELECT AVG(R.ImpactAverage) AS ImpactAverageAll,
AVG(R.EconomicalAverage) AS EconomicalAverageAll,
AVG(R.CulturalAverage) AS CulturalAverageAll,
AVG(R.SocialAverage) AS SocialAverageAll,
AVG(R.GeopoliticalAverage) As GeopoliticalAverageAll,
COUNT(R.SessionId) As SessionsPlayed
FROM ( SELECT TOP @MaxHits
ImpactAverage,
EconomicalAverage,
CulturalAverage,
SocialAverage,
GeopoliticalAverage,
SessionId,
CreationTime
FROM Sessions
ORDER BY CreationTime DESC ) AS R


In variable @MaxHits I provide the number of dataset I wanna have for my average calculations. So if I use this variable I get an SQL error message inside of Ventuz that there is a syntax error near my @MaxHits variable. If i replace the variable with a number like 1000 the query is executed without any problems and I get my results.

Any ideas why this error occurs?

Thanks,
Anton

Post Reply