Archives of the TeradataForum
Message Posted: Mon, 08 Sep 2003 @ 16:48:22 GMT
Subj: | | Re: LEAD/LAG Analysis |
|
From: | | Watzke, Michael |
No, the ordering in the analytical function's order by clause is NOT related to the output set ordering in the query statements order by
clause.
If I understand you scenario the query would look like this
SELECT sales_man_id,monthn,totalsales
,MIN(totalsales) OVER (PARTITION BY sales_man_id ORDER BY monthn ROWS
BETWEEN 1 preceding AND 1 preceding) as LAG
FROM t
order by sales_man_id, monthn;
If I misunderstand the scenario it would be helpful if you had the syntax you wanted to use expressed using the lead/lag syntax.
Mike
|