About 3,270,000 results
Open links in new tab
  1. Ordering by the order of values in a SQL IN() clause

    Aug 16, 2016 · Use MySQL's FIELD() function: SELECT name, description, ... FROM ... WHERE id IN([ids, any order]) ORDER BY FIELD(id, [ids in order]) FIELD() will return the index of the …

  2. How to Sort Values in a Specific Order in SQL - LearnSQL.com

    Oct 8, 2021 · It'll teach you how to use CASE expression in SQL queries and much more. We’ll demonstrate this SQL custom order by running through 3 distinct examples, involving different …

  3. How to ORDER BY the Order of Values in a SQL IN () Clause

    Sep 18, 2024 · In this tutorial, we’ll explore various methods of ordering the specified values in SQL results using the Baeldung University schema. 2. Using a CASE Statement. The SQL …

  4. SQL ORDER BY Examples to Sort and Order Data - SQL Server Tips

    Apr 10, 2023 · In this SQL tutorial, we will look at different ways you can use SQL to order data along with several examples in a Microsoft SQL Server database. Sorting result sets is done …

  5. Using the WHERE and ORDER BY Clauses in SQL - UniversalClass

    There is no guarantee that records are returned in a specific order when you don't use sorting options in SQL. In addition to sorting, you also use filtering options to return only specific …

  6. SQL - Select Rows in a Certain Order - Database Administrators …

    Jul 6, 2015 · Say my initial query SELECT * FROM businesses where name like 'a%' order by name returns ids like this: Above is if I want to get all the rows. But instead I'm trying to get …

  7. How to Use SELECT In Order BY Specific Ids in SQL?

    Dec 3, 2024 · By default, ORDER BY sorts the data in ascending order (ASC), but we can specify descending order (DESC) to reverse the order. It can be applied to a single column or multiple …

  8. Return SQL query results in order of input into WHERE clause

    Sep 16, 2016 · Goal: Return results of query in the same order that I input them into the WHERE clause. Example: Yes, the simplified query here runs, but the results are returned in the order …

  9. SQLrevisited: How to Sort or Order results in SQL query? ORDER

    Jan 12, 2024 · This guide will delve into the syntax of the ORDER BY clause, exploring its applications, limitations, and practical examples to empower SQL practitioners with the skills to …

  10. SQL ORDER BY Clause with 7 Examples - LearnSQL.com

    Sep 27, 2022 · In my experience, ORDER BY is one of the most useful SQL constructs; almost all reports and analyses have some use of it. Let me take you through an example that explains …

  11. Some results have been removed
Refresh