How can we help you today? How can we help you today?

Inconsistent new line behavior with windowed function

I've noticed that the ORDER BY list items within a windowed function do not follow the normal "Place first item on new line" settings. The following query was formatted using the "If there are subsequent items" option:
;WITH CTE AS
	(
		SELECT
			a = 1
		   ,b = 2
		   ,c = 3
		   ,x = 4
		   ,y = 5
		   ,z = 6
	)
SELECT Field = ROW_NUMBER() OVER (PARTITION BY
									  CTE.a
									 ,CTE.b
									 ,CTE.c
								  ORDER BY CTE.x	-- x ought to be on a new line
									 ,CTE.y
									 ,CTE.z
								 )
FROM CTE
ORDER BY
	CTE.x
   ,CTE.y
   ,CTE.z
Note that, though each list item in the PARTITION BY and the final ORDER BY statements are on new lines, the first list value within the windowed function's ORDER BY is still on the original line.
a.higgins
0

Comments

3 comments

  • David Priddle
    Hi a.higgins,

    You're right, the option for the first list item should be affecting ORDER BY in a windowed function, so we'll get this fixed for the next release.

    Best regards,

    David
    David Priddle
    0
  • David Priddle
    Hi a.higgins,

    We have put in a fix for this in the latest beta release.

    Please let us know if this solves your problem.

    Best regards,

    David
    David Priddle
    0
  • a.higgins
    The newest release takes care of this, thanks!
    a.higgins
    0

Add comment

Please sign in to leave a comment.