-- -------------------------------------------------------------------------------- -- Section Header -- -------------------------------------------------------------------------------- -- # Use a section header to describe the overall intention of the following -- SQL statement. -- # Use bullet points to structure the inline documentation. -- > If neceessary, you can use bullet points for sub-items, too -- > ... -- # In case of complex transformations add links to online document -- https://onedrive.live.com/?id=root&cid=ABCDEF0123456789 -- -------------------------------------------------------------------------------- SELECT -- -------------------------------------------------------------------------------- [EmployeeKey] -- # Inline documentation that occupies complete lines and that interrupts more or ,[FirstName] -- less the readability of a SQL statement can affect the comprehensibility of ,[LastName] -- the statement. ,[Title] -- # An essential criterion for the understanding of an SQL statement is not only a ,[ParentEmployeeKey] -- clear structure and formatting of the statement, but also whether the ,[VacationHours] -- statement is compact enough to get the major task on a short glance at the ,[SickLeaveHours] -- statement. -- # Use bullet points, too, for the parallel inline documentation -- # It is easier to navigate vertically through a document than horizontally. -- Keeping that in mind, limit the maximum length of inline documentation -- to e.g. 80 characters as in this example. -- # It may help to insert a separating line with 80 characters as an -- orientation for the maximum length -- 1-----------------------------------------------------------------------------80 ,NTILE(3) -- >> If the inline documentation refers exactly to the line of code on the left OVER (PARTITION BY [Level] -- side, you should mark the documentation with for example the characters '>>' ORDER BY [VacationHours] -- ) AS [VacationHours_NTILE] -- -- # If the inline documentation needs more lines than the SQL statement, just add -- these lines and leave the left part of the documentation blank. Blank lines -- do not affect the readability that much as inline documentation, that occupies -- complete lines. ,DENSE_RANK() -- >> This documentation would refer to the command DENSE_RANK() OVER (PARTITION BY [Level] -- >> This documentation would explain the PARTITION clause ORDER BY [VacationHours] -- >> ...and this documentation the ORDER BY statement ) AS [VacationHours_DENSE_RANK] -- ,NTILE(3) -- OVER (PARTITION BY [Level] -- ORDER BY [SickLeaveHours] -- ) AS [SickLeaveHours_NTILE] -- ,DENSE_RANK() -- OVER (PARTITION BY [Level] -- ORDER BY [SickLeaveHours] -- ) AS [SickLeaveHours_DENSE_RANK] -- FROM -- [dbo].[DimEmployee]; --