Skip to content
Advertisement

Tag: sql-order-by

using ORDER BY in SQL for chunks of data

I want to know how I sort data in a SQL query but only in certain chunks. I’ll provide an example to make it easier. In the above example, I want to do an ORDER BY height DESC, BUT only the tallest person of each rank gets ordered and everyone else in the same rank is right under that person

SQL Order By in Custom Sequence [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have data in this order How can I sort this data in this order? Answer To do this requires a big assumption which is

Sort by year as nvarchar and then numerically

I have an nvarchar column that in essence stores the following data: The first two numbers represent the year created and the last numbers represent the id of the unit made that year. Whenever I sort I get the 99’s first and 19 last. I’d like to sort by latest year first and then numerically. I have tried converting to

How to Sort this MySQL Query

I am trying to insert the ORDER BY in this query to sort the Total column: With the following result: Here’s what I have tried so far but no luck: Answer I think you want: Rationale: the ORDER BY clause should go after all UNION ALL subqueries – so it needs to be outside of the GROUP_CONCAT(), in an outer

How to understand the execution sequence of SELECT and ORDER BY

I googled the question and all answers said SELECT was executed before ORDER BY. But the simple example below (using MySQL and sakila database) gives the correct sorted results. Obviously, ORDER BY is not executed after SELECT, as customer_id is not selected by SELECT. Can anybody explain what happened? SELECT rental_date FROM rental ORDER BY customer_id LIMIT 10; Answer Is

Advertisement