LAG function

Copper Contributor

Hello,

I do have a problem using the LAG function in a View. I use:

LAG(Process_Time,1) OVER (ORDER BY Process_Time)

 

Problem is: As soon as I hit the retutn button it delets "OVER (ORDER BY Process_Time)", when I close the view it complains "OVER Clause missing" ???????

I am using Windows 10 and SQLExprss server 2014. The LAG function is rather simple, syntax is correct, why does it ignor the OVER clause???

Any Idea??

 

Thanks, regards, Peter

 

3 Replies

@Peter62270 , by "hitting return button" I guess you use a view design wizard?

The wizards are know for been not reliable and that they don't alway support new SQL features.

 

Install the lates SSMS version or better use always plain script to create objects.

@olafhelper 

Hi Olafhelper,

thanks for your advice. If entered directly as text it works but it is rather slow. I am using Access as a front end I may as well run this table through a little program code and calculate the time diffference, probably it is quicker this way. I will try and compare.

However, your advice was good. Thanks.

Regards

Peter

@Peter62270 , in MS Access you can use "Pass-Through" queries to pass it directly to SQL Server instead that Access process the query.