Tag: SQL

  • Making A Better Date

    In the last few posts, we’ve discussed different ways of “prettifying” – yes, a very technical word – dates. And no, we’re not talking about the kind you can eat or go on. Nope, we’re talking about this kind of date: Let’s say you’re busy coding along and you come to the realization that you…

  • Prettifying A Whole Mess of Dates

    In our last time together, we were talking about Doing more when trying to Convert. One of the many things I mentioned was using the CONVERT function to change a date to always look a particular way – for example, MM-DD-YYYY or DD/MM/YYYY. Since the CONVERT function requires you to either look up each time…

  • Doing more when trying to Convert

    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…

  • 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…

  • 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…

  • 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…

  • 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…

  • 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…

  • 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…

  • 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: Does it work?…