External Article

DAX CASE Statement Functionality with IF, SWITCH and SWITCH True

The CASE expression is one of the most valuable tools in your T-SQL toolbox. I use it in almost every query I write. However, there isn't a direct equivalent of CASE in DAX. Since it's a different language entirely, I don't expect it. As my grandmother used to say, I am not surprised, just disappointed. If you don't know, DAX (Data Analysis Expressions) is a language for creating custom calculations and aggregations in Power Pivot, Power BI, and other data analysis tools. Two functions in DAX come close to replicating the functionality but come with limitations. Which one of these functions should you use? Please stay tuned.

External Article

Piping, Filtering and Using Flyway Output in PowerShell

Flyway's output is often overwhelmed with verbose messages, most of which we can ignore but some of which provide vital warnings about failed compilations, or useful details about what a migration or callback did. I'll show how to use some pipeline-aware PowerShell functions to filter out and save the bits we want and pass the results along in a form that is useful to the next process in the pipeline.

External Article

Using TOP clause in a SELECT statement

There might be a time when you might want to return just a few rows of a result set, instead of the complete set. This might be useful if you want to just validate a selection criteria or a few rows of data. For whatever the reason the TOP clause can be used to return a specific number or a percentage of rows from a result set. This article will cover using the TOP clause in a SELECT statement and how it can be used to return a partial set of records.

Blogs

Free webinar – Tackling the Gaps and Islands Problem with T-SQL Window Functions

By

I’m hosting a free webinar at MSSQLTips.com at the 19th of December 2024, 6PM...

Counting Groups with Window Functions: #SQLNewBlogger

By

I looked at row_number() in a previous post. Now I want to build on...

Read the latest Blogs

Forums

Find rows with very close time stamps

By daytonbrown2

Given the following table and query, this will return any records(based on message_id) that...

How to merge two tables with unlike fields

By landonh

How to merge two tables with unlike fields. I have two table with one...

Visual Studio 22 / SSIS Project / (Project) Connection problem

By WilburSmith

Hello, First of all, I find it odd/annoying that I can't exclude a Project...

Visit the forum

Question of the Day

The LAGging NULL

I have this data in a SQL Server 2022 table:

player         yearid team HR
Alex Rodriguez 2012   NYY  18
Alex Rodriguez 2013   NYY  7
Alex Rodriguez 2014   NYY  NULL
Alex Rodriguez 2015   NYY  12
Alex Rodriguez 2016   NYY  9
If I run this code, what are the results returned in the hrgrowth column?
SELECT
  player
, yearid
, hr
, hr - LAG (hr, 1, 0) IGNORE NULLS OVER (ORDER BY yearid) AS hrgrowth
FROM dbo.playerstats;

See possible answers