Explain the below

Lag(expression [,offset [,default] ] ) over( [ Partition_By_clause] order by clause)

 Posted by Rajnilari2015 on 10/24/2015 | Category: Sql Server Interview questions | Views: 133 | Points: 40
Answer:

Expression => A table column or built-in function but not analytical functions

Offset => It is optional and represents the physical offset from the current row in the table. If not specified, the default value is 1 and cannot accept negative numbers.

Default = > It is again optional. If not specified, then whenever the offset value goes out of the table bounds, then default null is returned.

Partition_By_clause = > Partition the query result set. It is again optional

Order By Clause = > Indicates how the data is ordered within the partition.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response