In the earlier segments, you learnt how to calculate moving averages in SQL using frames. Identifying frequent customers is a commonly observed business requirement for retail chains. The ‘lead’ and ‘lag’ functions can be quite helpful in this case. You can compare the date on which a particular customer purchased an item from a store with the next date on which they ordered an item again. In the upcoming video, you will learn more about the ‘lead’ and ‘lag’ functions as well as their use cases.
So, as explained in this video, another use case of the ‘lead’ and ‘lag’ functions is to determine whether consecutive orders were shipped using the same shipping mode. This can be extremely helpful in optimising the shipping and delivery of products.
The syntax for using the ‘lead’ and ‘lag’ functions are as follows:
In the next video, you will see a practical example of determining the frequency at which a customer named Rick Wilson orders products, using the ‘lead’ and ‘lag’ functions on the ‘market star schema’.
With this, you have come to the end of this session. You learnt about various concepts in this session, so let’s summarise the topics and the syntax for some of the advanced SQL concepts in the final segment.