TSQL: How to use LEAD() and LAG() functions in analytic data

Problems I have a data set that describe Sales data of all categories. Now I need to build a query to compare┬áSales of a given year with previous year for each┬ácategory. For example, I have a data set of SALES Now, I need to build a report to analyze how much sales of previous year … Continue reading TSQL: How to use LEAD() and LAG() functions in analytic data

Advertisements

TSQL: Working with PIVOT in SQL Server

Problem You have a data in your database as below: So now, you need to build a report┬áSales By Branch Solution There are many ways to implement any report like above. The most popular way is PIVOT technique in SQL Server. Ideally, PIVOT is used to convert rows to columns. To understand how it works, … Continue reading TSQL: Working with PIVOT in SQL Server