Ability to order by multiple columns
See original GitHub issueFeature request
Is your feature request related to a problem? Please describe.
I don’t see a way to order by multiple columns. Here’s what I would do in SQL:
SELECT
first_name,
last_name
FROM
customer
ORDER BY
first_name ASC,
last_name DESC;
Describe the solution you’d like
I’d like the order()
method to accept multiple columns. Here’s an idea:
const { data, error } = await supabase
.from('customer')
.select('first_name', 'last_name')
.order([
{ column: 'first_name', ascending: true },
{ column: 'last_name', ascending: false },
])
Describe alternatives you’ve considered
I tried multiple .order
methods and this didn’t appear to work (maybe I screwed up the logic?)
const { data, error } = await supabase
.from('customer')
.select('first_name', 'last_name')
.order('first_name', { ascending: true })
.order('last_name, { ascending: false });
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Solved: Sorting a table using multiple columns
If you want to sort a table by multiple columns, the only option you have is to have a concatenated column with the...
Read more >How To Sort A Table Using Multiple Columns In Power BI
Press Shift + Left Click on the Header Column on which you wish to apply Multiple Sort. Here, we will select the Order...
Read more >SQL - Multiple Column Ordering - GeeksforGeeks
Order By: It is used to sort the result-set in ascending or descending order. It sorts the records in ascending order by default....
Read more >Sort data (Power Query) - Microsoft Support
Sort data based on multiple columns · To open a query, locate one previously loaded from the Power Query Editor, select a cell...
Read more >Sorting a Power BI table by multiple columns
– There is no limit on the number of columns that can be used to sort a table. Just hold the shift key...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hm, that should work, it’s tested here:
https://github.com/supabase/postgrest-js/blob/5f47e84e917448d792c89e5be29c2f643c2a82ab/test/transforms.ts#L12-L19
Can you double check? Perhaps share some sample data and the supabase-js output.
@spyl94 Cool! Thanks for confirming.
To close this one I think we’d need an additional example(“ordering multiple columns”) here: https://supabase.com/docs/reference/javascript/order#examples