Skip to main content

Questions tagged [sql-order-by]

An ORDER BY clause in SQL specifies that a SQL SELECT statement returns a result set with the rows being sorted by the values of one or more columns.

Filter by
Sorted by
Tagged with
0 votes
3 answers
179 views

Here is an extract of table B_TimeEntryMatter. ProformaNr ActivDate Description 451894 17/12/2025 To the provision of a Certificate of Incumbency by the Secretary; 451894 18/12/2025 To time spent in ...
user32213456's user avatar
0 votes
0 answers
78 views

I’m using Manticore Search 14.1.0 (Docker image manticoresearch/manticore:latest) on Ubuntu 20.04.6 LTS. I rely on cursor-style pagination with OPTION scroll, but when the sort clause includes a ...
Meet Vadodariya's user avatar
5 votes
4 answers
250 views

I need to sort a query's results by two methods at the same time. I want the first 3 records (returned) to be based on their prevalence in another table And then I want the rest of the results sorted ...
Gavin Baumanis's user avatar
-2 votes
1 answer
75 views

Mainly, I want to order the ids in descending direction but also, how can I sort parent product/items (the ones with empty ean) first and their child rows below them? Here's an example data from the ...
Jeremy's user avatar
  • 1
4 votes
2 answers
179 views

I have a table in Postgres (14) that is used like a queue with FOR UPDATE SKIP LOCKED queries. It was missing an index, but since any rows are usually processed ...
Tamas Kozma's user avatar
4 votes
1 answer
205 views

I need to implement keyset pagination (sometimes referenced as cursor-based or seek method) in Postgres with the following ordering rules: Rows where ...
Geba's user avatar
  • 3,453
0 votes
2 answers
113 views

In my application I want to find the latest duty of each user from 'StaffDuty' table using hibernate query (i.e. HQL). Below is my query. ...
KJEjava48's user avatar
  • 2,073
1 vote
2 answers
72 views

I'm exploring the use of ArrayAgg and I don't understand why 'histidine-[13C6,15N3]' doesn't occur before ...
hepcat72's user avatar
  • 1,225
1 vote
2 answers
93 views

I have 3 tables in SQL: Agency, booking and checkin (and rooms) I need to compute a % of checkin / booking, by week number (of begin), by agency Here somes tables for example Agency : id name 1 first ...
Emmanuel's user avatar
0 votes
2 answers
141 views

I have the following stored procedure: ...
TheIronCheek's user avatar
  • 1,241
0 votes
2 answers
127 views

I have the below dataset which includes 3 columns: Inspection Id Inspection Date Fault Number Note: I have added in the 2 additional columns 'Comment' and 'Required Sort Order' to help explain what ...
BuckBuchanan's user avatar
0 votes
0 answers
57 views

Been trying to order the custom post type listing page based on a custom meta field. the meta field value would be in the form of string and number (pattern: '[string][unsigned]')(examples: 'A1','A2',....
Crystal Paladin's user avatar
2 votes
2 answers
141 views

Having this situation: SELECT DISTINCT "FieldName" FROM "TableName" ORDER BY "FieldName" ASC; I'd like to have the lines containing ...
StOMicha's user avatar
  • 501
1 vote
2 answers
129 views

Is there a way to efficiently order by a text field in a join query (i.e., fast on large datasets)? I understand that I probably need to filter the dataset somehow, to reduce the size of the dataset ...
Oskan's user avatar
  • 21
1 vote
2 answers
97 views

I have the following folders table: ...
John's user avatar
  • 1
0 votes
1 answer
94 views

I’m optimizing a query for better performance, and I use the following SQL statement: ...
Ruibin Zhang's user avatar
0 votes
1 answer
62 views

I have a query in Oracle where I need to: Order the entire table by a specific column. Select and lock a certain number of rows using SELECT FOR UPDATE. However, the issue is that Oracle first selects ...
Sa_am's user avatar
  • 29
1 vote
0 answers
69 views

I defined a redshift table (some fields omitted from this sample) with this DDL: ...
PunDefeated's user avatar
1 vote
1 answer
151 views

I have a base razor component, that loads data from a SQL database. To pass a sort order to this component, there are two "sort" Func<T,object> parameters and two bool to set asc/desc. ...
Helmut's user avatar
  • 502
0 votes
2 answers
121 views

I have a model Release. Each release has a type, and depending on that type different types of Credit are considered primary ...
bur's user avatar
  • 899
2 votes
6 answers
121 views

I want to arrange pending orders by eta in asc order and completed orders in desc order, with all completed orders appearing at the bottom of the list. Not sure if this is possible in a single query. ...
nj167252's user avatar
  • 173
-2 votes
1 answer
106 views

Any known explanation of this? Why Order By ASC doesn't return any item but order by DESC doesn't? I am using postgres with pg_vector extension ...
Sudip Mondal's user avatar
-2 votes
3 answers
85 views

I would like to get my entries ordered by a specific pattern. For example I have an array like this arr = [2,5,3,9,4] Now I want to get the entries from my db by ...
Ilan Sagital's user avatar
0 votes
0 answers
66 views

I use spring boot, and I want to add specific days to date column in mysql database on hql query order by clause. But which results error when I tried. I need to get results in the order of adding ...
KJEjava48's user avatar
  • 2,073
-2 votes
1 answer
54 views

I have a pretty basic Yii2 ActiveRecord query. $paperList = Paper::find()->orderBy(['id' => SORT_DESC])->all(); id is my primary key column which is of ...
Quentinb's user avatar
  • 510
-1 votes
2 answers
57 views

Using : sum(Age) over(partition by Country) as Total ...
jessejbweld's user avatar
0 votes
1 answer
121 views

I have this query: ...
Eric's user avatar
  • 941
1 vote
0 answers
57 views

I've got a custom post type for staff. The fields are first_name, last_name, job_title, telephone, email, and notes. All staff are categorized by location using WP core Category. I need to output the ...
banacan's user avatar
  • 115
0 votes
2 answers
69 views

I have a table Users with id, this table has a million records or more. So when fetching data from the table I am using batching with offset & limit to reduce ...
Manu S Rao's user avatar
0 votes
1 answer
229 views

I have a query in Snowflake where I am returning both numeric and varchar values and am struggling with getting the sort to work correctly. For context, this column is calculated by dividing two ...
BenTen's user avatar
  • 503
1 vote
3 answers
138 views

I'm trying to execute a SQL query with a left join with sum, group by and ...
dlaksmi's user avatar
  • 213
0 votes
3 answers
147 views

In an Oracle SQL query which uses binary sorting rules, numbers are sorted before letters. But if the query uses a language specific collation to enable linguistic sorting, then numbers are sorted ...
cremor's user avatar
  • 6,955
1 vote
3 answers
124 views

In an Oracle SQL query which uses binary sorting rules, numbers are sorted before letters. But if the query uses a language specific collation to enable linguistic sorting, then numbers are sorted ...
cremor's user avatar
  • 6,955
0 votes
1 answer
70 views

Example Fiddle ...
Ben Holness's user avatar
  • 2,744
0 votes
1 answer
80 views

I'm trying to select query from record count more than 1 (ID&DATE&INOUT) and count more than 2 (ID&DATE) with custom column (Option) in MS Access so with "NO" in the option ...
dlaksmi's user avatar
  • 213
1 vote
1 answer
105 views

I've got a table with a column of BANK_ID alphanumeric (VARCHAR2 in Oracle, VARCHAR in SQL ...
AddicksAddict's user avatar
1 vote
2 answers
173 views

I'm trying to select query from row count more than 2 based on ID and DATE and OPTION in MS Access. so with "NO" in the option column then the record more than 2 is not included in my sql ...
dlaksmi's user avatar
  • 213
1 vote
1 answer
87 views

I'm trying to select query from row count more than 2 based on ID and DATE in MS Access. Please Guide me I want to keep it as a single query. Thanks Table Absen ID ...
dlaksmi's user avatar
  • 213
0 votes
2 answers
78 views

Suppose there is a list of clients and each client has different contracts that have a due date. For each client, I want to select the contract with the first following duedate after a given reference ...
Hanne DC's user avatar
0 votes
1 answer
93 views

I'm working on a Flask application using SQLAlchemy where I need to consistently sort URLs stored in a database. The goal is to have a consistent ordering of competitor URLs so that when comparing ...
Marino's user avatar
  • 1
0 votes
4 answers
77 views

Given: ...
hyankov's user avatar
  • 4,135
-1 votes
1 answer
55 views

Id Child_one_id Child_two_id Parent_id 1 2 3 null 2 null null 1 3 2 null 1 4 null null null 5 6 7 null 6 null null 5 7 6 null 5 8 null null null 9 null null null 10 11 12 null 11 null null 10 12 null ...
Karthikeyan Sankar's user avatar
0 votes
3 answers
61 views

I get different sorting results when trying the same select on two different clients. This is a simple example: ...
miran213's user avatar
1 vote
2 answers
41 views

I have simple table of Time and Task columns where it is ordered by Time and has associated task to it as per below example. Question: How to group the tasks and get the earliest time of every time ...
Avia Portal's user avatar
0 votes
1 answer
162 views

I need to replicate the exact order produced by another program that used the ORDER BY clause in its SQL query: ...
user23787413's user avatar
1 vote
1 answer
283 views

I want to use SELECT WITH ROLLUP in MariaDB to get a summary row in the result set, but also order the remaining rows by ...
Eugene Yarmash's user avatar
1 vote
0 answers
57 views

I tried to write belowed SQL with CriteriaAPI in Hibernate 6.2.6: ...
dtadescu's user avatar
1 vote
0 answers
67 views

I am trying to orderby value of a Map that is included in my @Entity as @CollectionTable @ElementCollection. I try to do this using criteriabuilder and eclipselink. I provide below the entity example <...
geminal's user avatar
  • 29
0 votes
1 answer
47 views

My written query is:- Query 1: ...
drrracula's user avatar
0 votes
0 answers
55 views

I need help to find out why this behaviour (not a solution). It's about the ORDER BY clause in SQL Server. It has nothing to do with the related post, because my case it's not about case sensitive/...
plionut's user avatar
  • 19

1
2 3 4 5
155