James.Rivers (12/3/2014)
Thanks for all your responses.I wanted to avoid creating a temp table for this process so I have opted to use the
SELECT LocationId, MaterialId, Duration
FROM (
SELECT LocationId, MaterialId, Duration,
VAR(Duration) OVER (partition by MaterialID) AS VarDuration
FROM #t
) d
WHERE VarDuration > 0
However this syntax at (partition is reported as an an error code 1064..... Odd.
Is Partition valid in MySQL?
I think I have posted in the wrong forum..... apologies... Not totally awake ๐
It works in current versions of SQL Server and DB2. No idea if it works with MySQL, sorry.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden