The last time we met, we discussed the glorious try_convert function and how it can save us from “not-so-datey” dates. Most of the time, at least in a business setting, we don’t want to display NULLs to our users, so in many cases, we’re asked to put a placeholder if there is a NULL. We…… Continue reading Doing more when trying to Convert
Telling data to act like other data
When messing with data, sometimes you want to change how SQL Server sees the data. For that, you would want to use the CONVERT command. There are many great reasons to do this and thankfully some of our datasets have some great possibilities that you can work with. For example, after looking at the Nirvana…… Continue reading Telling data to act like other data
The End of the TOP
After dealing with TOP and ROWCOUNT in SQL Server, there is one more way of getting a limited amount of data from a query that you should be aware of – OFFSET/FETCH. It can be a little bit more difficult to set up and work with but if you’re in need of the data a…… Continue reading The End of the TOP
Not Quite To the Top
After the past few blog posts, I’m sure you’re like “Sherpa! How many more things can we learn about the TOP Operator?” My friends, the answer is “Still more!” Today, let’s go over an option that can be used in conjunction with TOP. That option is SET ROWCOUNT (Number); This option has the potential to…… Continue reading Not Quite To the Top
There Has to be Room at the TOP!
In our continuing adventures with the TOP operator in SQL, we’ve seen it do a lot of things that probably aren’t obvious when you first think about using TOP – especially if you’ve been using SQL for a while. Let’s say that our wonderful Product team asks us to get the top 1 % of…… Continue reading There Has to be Room at the TOP!
What to do with TOP when there are ties
In the last few blog posts – see here and here – we’ve been discussing the usage of the TOP operator. The product team will often ask for the top 5 of something or even the top 10% of performers in a subregion. There’s an additional part to the TOP operator that you won’t see…… Continue reading What to do with TOP when there are ties
Getting the TOP Performers
In the last blog post, we went over the extreme basics of using the TOP operator in SQL. We showed how to grab things like the TOP 10 of a certain item. That ability will get you through a number of criteria that you will be asked to perform. But what if you’re asked to…… Continue reading Getting the TOP Performers
TOP of the Mornin’ to You!
Sometimes you find yourself stuck in a rut and you never even know that there is a rut. That’s where I found myself today my friends! For years – and I do mean years – when I’ve been asked for the first 10 rows from a query, I would do the following: SELECT TOP 10…… Continue reading TOP of the Mornin’ to You!
More Fun with Smushing Data Together
Last week, we learned all about the old-style string concatenation and the new-ish, hip CONCAT function. This week, it’s time to talk about the CONCATs lesser talked about, but equally helpful cousin – CONCAT_WS. With CONCAT, we formatted the person’s name in a LastName, FirstName format using the following query. SELECT CONCAT(TRIM(LastName), ‘, ‘, TRIM(FirstName))…… Continue reading More Fun with Smushing Data Together
Sometimes You Need to Push Strings Together
Every now and again, you’re probably going to have to slap a few strings together in your fun with SQL. A long time ago (20 years ago), in SQL Server world, there was only one way to do it – and sadly, you’ll probably see many developers still doing it this way. SELECT LastName +…… Continue reading Sometimes You Need to Push Strings Together