<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>SQL on Thiago Araujo</title>
    <link>https://thdaraujo.github.io/tags/sql/</link>
    <description>Recent content in SQL on Thiago Araujo</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 10 Jun 2021 11:53:56 -0700</lastBuildDate><atom:link href="https://thdaraujo.github.io/tags/sql/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to Write a Clean Order By Case Query with Arel on Rails</title>
      <link>https://thdaraujo.github.io/posts/how-to-write-order-by-case-query-with-arel/</link>
      <pubDate>Thu, 10 Jun 2021 11:53:56 -0700</pubDate>
      
      <guid>https://thdaraujo.github.io/posts/how-to-write-order-by-case-query-with-arel/</guid>
      <description>You&amp;rsquo;re working on a feature and someone tells you that one of your models needs to be ordered based on some complicated rule. You realize you&amp;rsquo;ll need to write a complex order by query&amp;hellip;
Here&amp;rsquo;s how it usually goes:
 You think to yourself: &amp;ldquo;Should I write an order by case when statement? Maybe I&amp;rsquo;ll just add a little bit of SQL&amp;hellip;&amp;quot; Two minutes later, you end up with a bunch of nested case when statements, subqueries, common table expressions, angry statements, shouting, and a whole lot of tears.</description>
    </item>
    
  </channel>
</rss>
