# Sorting Data in Postgres via If-\>Then-\>Else

**URL:** <https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125>\
**Category:** Ask for Help\
**Created:** [February 25, 2024, 3:01am UTC](https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125 "2024-02-25T03:01:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlphaBCD](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alphabcd/32/56402_2.png) [@AlphaBCD](https://community.glideapps.com/u/AlphaBCD)\
**Post date:** [February 25, 2024, 3:01am UTC](https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125/1 "2024-02-25T03:01:55Z")

</div>

Is there a way to sort via If-\>Then-\>Else? I was able to do it with Glide Tables, but not with Postgres source. Is there a workaround or do I have to do it in the SQL table?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 25, 2024, 3:26am UTC](https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125/2 "2024-02-25T03:26:43Z")

</div>

Yeah, it looks like sorting by computed columns is [not supported](https://www.glideapps.com/docs/essentials/data-sources/postgresql#aggregation-limitations). So you’ll probably need to do something in the source table to get the values you need into non-computed columns (as Glide sees them).

---

<div class="post-metadata">

**Author:** ![Kartik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kartik/32/37220_2.png) [@Kartik](https://community.glideapps.com/u/Kartik)\
**Post date:** [February 25, 2024, 5:09am UTC](https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125/3 "2024-02-25T05:09:00Z")

</div>

You mean to say that because of computed column, sorting feature will not be supported in other than Glide tables, am I right ?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [February 25, 2024, 5:24am UTC](https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125/4 "2024-02-25T05:24:38Z")

</div>

No, not exactly. I was just referring to SQL data sources, which is what the question was related to. If you have a read of the document I linked to, hopefully that will make it clearer.

---

<div class="post-metadata">

**Author:** ![AlphaBCD](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/alphabcd/32/56402_2.png) [@AlphaBCD](https://community.glideapps.com/u/AlphaBCD)\
**Post date:** [February 28, 2024, 3:58am UTC](https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125/5 "2024-02-28T03:58:46Z")

</div>

Thanks Darren. Will update in the SQL table but would be a great feature to have 👀 🍀. Bit more complicated to get set up in SQL.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [March 6, 2024, 3:59am UTC](https://community.glideapps.com/t/sorting-data-in-postgres-via-if-then-else/71125/6 "2024-03-06T03:59:31Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
