Query a JSON array in SQL
For the purpose of this post, lets not evaluate the db design option and lets focus on the operations on the json column.
Lets say we have a table of...
.NET EF Core 6 support for groupby top(n) queries
EF Core 6 comes with some GroupBy queries improvements. In this post I wanna talk about the improvements related to "group by top(n)" queries.
Let's say we have the following...
Converting a Vertical Table to an Horizontal Table in SQL Server
Today I've encountered a vertical table in an SQL Database and I wanted to transform it to an horizontal one. A vertical table is described as an EAV model.
Imagine...
How to Access the Previous Row and Next Row value in SELECT statement?
LAG - http://msdn.microsoft.com/en-us/library/hh231256.aspx
USE AdventureWorks2012;
GO
SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota,
LAG(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS PreviousQuota
FROM Sales.SalesPersonQuotaHistory
WHERE BusinessEntityID = 275...