Category "sql-order-by"

Sort dynamic model with orderby

I am combining 2 tables that I transferred to the dynamic model into 1 table in the cshtml part. And I want to sort that table by a column(OrderBy). How can I d

How do I return single orderid having same rank?

I have the following output: Orderid Time State Order_rank 1 10.15 mfr 1 1 10.15 delivered 1 2 12.10 picked 1 2 12.10 mfr 1 Here I have ranked the order ids w

Order By Date desc evaluates 01-01-1970 higher then everything else

I have the following simplified query SELECT id to_char(execution_date, 'YYYY-MM-DD') as execution_date FROM schema.values ORDER BY execution_date DESC,

Alphabetic ranking a list with set of 'WITH TIES - ORDER BY (multiple fields)

A regular usage of "WITH TIES" & the result of the query : Demand: The best of 10 movies as Oscar Wins SELECT TOP 10 WITH TIES F.FilmName AS TITLE,

Deterministic sort order for window functions

I've a status table and I want to fetch the latest details. Slno | ID | Status | date 1 | 1 | Pass | 15-06-2015 11:11:00 - this is inserted first 2

SQL for ordering by number - 1,2,3,4 etc instead of 1,10,11,12

I’m attempting to order by a number column in my database which has values 1-999 When I use ORDER_BY registration_no ASC I get…. 1 101 102 10

PostgreSQL ORDER BY with VIEWs

Let's say I want to write a simple SELECT query that uses a VIEW: CREATE TEMP VIEW people AS SELECT p.person_id ,p.full_name ,p.phone FROM person

MySql Query to find out first 50% of records from a Table

I am trying to fetch first 50% of records from a MySQL Table User. I know we can use limit or top for finding them but the total number of records are not fixed

Determine whether an IQueryable<T> has been ordered or not

Is there a way to know if an IQueryable<T> has been ordered (using OrderBy or OrderbyDescending)? So I know whether to call OrderBy or ThenBy on the coll

Select last n rows without use of order by clause

I want to fetch the last n rows from a table in a Postgres database. I don't want to use an ORDER BY clause as I want to have a generic query. Anyone has any su

How to order results of a query by the results of an aggregate function in ComosDb?

I use Cosmos Db and I need results to be sorted by the results of a COUNT. Instead of sorting the results each time myself (or create a service for it), I pre

Sql Server query varchar data sort like int

I have one table like CREATE TABLE table_name ( P_Id int, amount varchar(50) ) Data Like Id amount ---------- 1 2340 2 4568 3 10000 Now I want to sort t