strange Sql Server error
-
Hello . I am quite a beginner in Sql Server, I am testing some simple sql code on Sql Server 2012. I have a table called "
AcctTransaction
" composed by 4 columns :AccountId as Int,
TransactionId as Int,
TransactionDate as DateTime,
Amount as Decimal (a8,4)I am trying to make this simple query work :
SELECT AccountId
,SUM(Amount) OVER (PARTITION BY AccountId) AS FinalBalance
,SUM(Amount) OVER (PARTITION BY AccountId ORDER BY TransactionDate, TransactionId
) AS ProgressiveBalance
FROM AcctTransactionI keep getting the following error :
Incorrect syntax near "order" and in effect if I comment out the
,SUM(Amount) OVER (PARTITION BY AccountId ORDER BY TransactionDate, TransactionId ) AS ProgressiveBalance
statement, everything works correctly. What's wrong with that statement ? I've made this query copying almost identically a sql statement I saw in a Microsoft course, where it seems to work perfectly.... Thanks to everyone who would answer ...
-
Hello . I am quite a beginner in Sql Server, I am testing some simple sql code on Sql Server 2012. I have a table called "
AcctTransaction
" composed by 4 columns :AccountId as Int,
TransactionId as Int,
TransactionDate as DateTime,
Amount as Decimal (a8,4)I am trying to make this simple query work :
SELECT AccountId
,SUM(Amount) OVER (PARTITION BY AccountId) AS FinalBalance
,SUM(Amount) OVER (PARTITION BY AccountId ORDER BY TransactionDate, TransactionId
) AS ProgressiveBalance
FROM AcctTransactionI keep getting the following error :
Incorrect syntax near "order" and in effect if I comment out the
,SUM(Amount) OVER (PARTITION BY AccountId ORDER BY TransactionDate, TransactionId ) AS ProgressiveBalance
statement, everything works correctly. What's wrong with that statement ? I've made this query copying almost identically a sql statement I saw in a Microsoft course, where it seems to work perfectly.... Thanks to everyone who would answer ...
-
A sudden thought ... is it possibile that I am getting this error only because I am using the Express version of Sql Server 2012 ? Maybe the express version, being not complete, lacks the "LAG" function.... Just a random thought .....
Are you sure you're using SQL 2012? I've just tried an equivalent query on my copy of 2012 Express, and it works perfectly.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Are you sure you're using SQL 2012? I've just tried an equivalent query on my copy of 2012 Express, and it works perfectly.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Well, that's what it says on "Help | About" section from the top menu .... Other infos are : Microsoft SQL Server Management Studio 11.0.2100.60 Microsoft Data Access Components (MDAC) 6.1.7601.17514 Microsoft MSXML 3.0 4.0 5.0 6.0 Microsoft Internet Explorer 9.11.9600.17801 Microsoft .NET Framework 4.0.30319.34209 Operating System 6.1.7601 Is it possible I have some components that's missing ?
-
Well, that's what it says on "Help | About" section from the top menu .... Other infos are : Microsoft SQL Server Management Studio 11.0.2100.60 Microsoft Data Access Components (MDAC) 6.1.7601.17514 Microsoft MSXML 3.0 4.0 5.0 6.0 Microsoft Internet Explorer 9.11.9600.17801 Microsoft .NET Framework 4.0.30319.34209 Operating System 6.1.7601 Is it possible I have some components that's missing ?
You might be using SQL 2012 Management Studio, but are you connecting to a SQL 2012 instance? Try running:
SELECT @@VERSION
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
You might be using SQL 2012 Management Studio, but are you connecting to a SQL 2012 instance? Try running:
SELECT @@VERSION
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer