tagged [sql-order-by]

Make zero appear last in a sorted list of integers

Make zero appear last in a sorted list of integers I have a list of objects and want to order them by some property The catch is that when `DisplayOrder` is zero I need to place that item in position....

23 May at 11:46

MySQL ORDER BY question

MySQL ORDER BY question How can I add an order by `users_friends.date_created` that governs both select queries. Here is my MySQL code. ``` (SELECT A.user_id, A.friend_id, B.username, B.avatar FROM us...

22 Oct at 10:38

ServiceStack ormLite chaning OrderBy

ServiceStack ormLite chaning OrderBy I am trying to so the following: The above works perfectly. But I want a rather more generic approach and parse a string like sort="field1,field2". I have the foll...

31 Oct at 19:34

LINQ Orderby Descending Query

LINQ Orderby Descending Query I have a LINQ query that I want to order by the most recently created date. I tried: I have also tried: ``` var itemList = (from t in ctn.Items where

30 May at 14:0

SQL Order By Count

SQL Order By Count If I have a table and data like this: and I wish to order it according to the total of Group from smallest to largest value, such as : A - 2 records , B - 1 record , C - 3 records ,...

24 Jan at 06:44

Can I do a max(count(*)) in SQL?

Can I do a max(count(*)) in SQL? Here's my code: Here's the question: > Which were the busiest years for 'John Travolta'. Show the number of movies he made for each year. Here's the table structure: `...

Best way to save a ordered List to the Database while keeping the ordering

Best way to save a ordered List to the Database while keeping the ordering I was wondering if anyone has a good solution to a problem I've encountered numerous times during the last years. I have a sh...

30 Jun at 20:15

Order a List (C#) by many fields?

Order a List (C#) by many fields? I want to order a List of objects in C# by many fields, not just by one. For example, let's suppose I have a class called X with two Attributes, A and B, and I have t...

18 Jan at 20:10

ORDER BY date and time BEFORE GROUP BY name in mysql

ORDER BY date and time BEFORE GROUP BY name in mysql i have a table like this: i want oldest name first: (->doesn't work!) now it should give me first mad(has earlier date) then tom

2 Feb at 13:49

Order by multiple columns with Doctrine

Order by multiple columns with Doctrine I need to order data by two columns (when the rows have different values for column number 1, order by it; otherwise, order by column number 2) I'm using a `Que...

24 Jan at 06:23

GROUP_CONCAT ORDER BY

GROUP_CONCAT ORDER BY I've [a table](http://googledrive.com/host/0B53jM4a9X2fqfkhfeV83Tm05VnU4cV9ZSWZlMUNTQzRZUUJQTFdQZUptOEJkdXkyVXFIYmM) like: ``` +-----------+-------+------------+ | client_id | vi...

30 Apr at 20:41

Problems with OrmLite query OrderBy method

Problems with OrmLite query OrderBy method I am having a few related problems with the OrderBy method when generating a query for OrmLite. The following two statements work: But the following statemen...

OrderBy and Top in LINQ with good performance

OrderBy and Top in LINQ with good performance What is a good way to get the top 10 records from a very large collection and use a custom `OrderBy`? If I use the LINQ to Objects `OrderBy` method it is ...

Linq Query with SUM and ORDER BY

Linq Query with SUM and ORDER BY I have a (C#) class called Hit with an ItemID (int) and a Score (int) property. I skip the rest of the details to keep it short. Now in my code, I have a huge List on ...

4 May at 15:47

Select one column, order by another

Select one column, order by another I'm using LINQ to SQL to select from a database. I want to select one column that consists of values that are `String`, but order by another column that contains a ...

17 Aug at 02:46

Orderby() not ordering numbers correctly c#

Orderby() not ordering numbers correctly c# I am writing an app for my company and am currently working on the search functionality. When a user searches for an item, I want to display the highest ver...

Linq order by, group by and order by each group?

Linq order by, group by and order by each group? I have an object that looks something like this: I would like to create the following query: group grades by student name, order each student group by ...

8 Sep at 20:38

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

Determine whether an IQueryable has been ordered or not Is there a way to know if an `IQueryable` has been ordered (using `OrderBy` or `OrderbyDescending`)? So I know whether to call `OrderBy` or `The...

21 Mar at 08:11

Using union and order by clause in mysql

Using union and order by clause in mysql I want to use order by with union in mysql query. I am fetching different types of record based on different criteria from a table based on distance for a sear...

24 Jul at 09:51

How to OrderBy an integer in a string field in a Linq query

How to OrderBy an integer in a string field in a Linq query I have some data coming out of an DB that I can't readily change the schema of. I want to sort it and bind it to a control based on a numeri...

Problem using OrderBy with the entity framework and ObjectContext.CreateQuery(T)

Problem using OrderBy with the entity framework and ObjectContext.CreateQuery(T) I'm having troubles using this method: I'm not sure

How to OrderBy on a generic IEnumerable (IEnumerable<T>) using LINQ in C#?

How to OrderBy on a generic IEnumerable (IEnumerable) using LINQ in C#? In my generic repository I have below method: T is a Linq to Sql class and I want to be able to OrderBy on a particular property

5 May at 22:55

How to avoid OrderBy - memory usage problems

How to avoid OrderBy - memory usage problems Let's assume we have a large list of points `List pointList` (already stored in memory) where each `Point` contains X, Y, and Z coordinate. Now, I would li...

25 Jul at 17:36

Ordering by the order of values in a SQL IN() clause

Ordering by the order of values in a SQL IN() clause I am wondering if there is away (possibly a better way) to order by the order of the values in an IN() clause. The problem is that I have 2 queries...

4 Jun at 10:14

Use own IComparer<T> with Linq OrderBy

Use own IComparer with Linq OrderBy I have a generic where `MyClass` has a property `InvoiceNumber` which contains values such as: 200906/1 200906/2 .. 200906/10 200906/11 200906/12 My list is bound t...

24 Jun at 01:21