Recently we’ve been looking at temporal tables including the basics for using them and options for querying them. Continuing with this theme – and given that tables rarely remain static – we’ll look at what we might need to consider when modifying their structure. As with the previous posts we’ll start our with our sample […]
Category: SQL
This month’s invitation from Kenneth Fisher asks us to share our first tech job. As he points out there are a lot of DBAs who don’t start out working with databases and we slowly succumb to the dark side (my words, not his), intentionally or otherwise. During a gap year whilst at university I joined […]
Querying Temporal Tables
During our initial introduction we briefly saw how to query temporal tables but there were a couple of specific bits which I wanted to cover around querying these tables. The first of these concerns the point in time we query against and the second is how we go about using that point in time to […]
Diving Deeper into Temporal Tables
Last time out we took a brief look at temporal tables, how to create them and what they can do for us. This time I’d like to dive a bit deeper into them and see how they look under the covers. For this we’ll be using the same table which we ended up creating previously: […]
Introduction to Temporal Tables
With the arrival of SQL Server 2016 we were provided with a new feature in the engine called System Versioned Temporal Tables – typically shortened to Temporal Tables. These tables allow us not only to query the data as it currently is, but also query it at any point in the past too as it […]
This month’s invitation from Camila Henrique asks us for advice we’d give to our younger selves in our T-SQL journey. Coming from the SQL Server perspective there’s a huge variety of areas within the stack where you might want to provide some advice but I’m going to focus on the scripting and querying as that’s […]
Dynamic Date Ranges with Window Functions
After recently covering window functions I thought it would be a good opportunity to share one of my favourite use cases for them. The functions for ranking and aggregations have their own clear use cases but here I’d like to discuss a particular use for the LAG and LEAD functions. The scenario There are instances […]
Analytical Window Functions
In the previous posts we covered the ranking and aggregate window functions and this time we’ll be finishing the series covering the Analytic functions, seeing what an alternative to Window Functions might look like, and then wrapping up what we’ve covered in this series of posts. As with our previous examples we’ll set up our […]
Aggregate Window Functions
Last time out we talked about the Ranking options which are available for Window Functions. This time we’ll be covering the Aggregate options which are available to us with them. We’ll also introduce a new feature to see how we can limit the rows the function is performed on, but different to the PARTITION method. […]
Window Functions and Ranking
Introduction Window Functions in SQL Server are functions which can be applied in the SELECT portion of a statement and will return a value relative to other records in the same data set. These functions differ from standard functions such as aggregates where those would combine multiple records together to come up with a result […]